diff --git a/tests/composer/test_blueprints.py b/tests/composer/test_blueprints.py index caa6b7c9..c073b336 100644 --- a/tests/composer/test_blueprints.py +++ b/tests/composer/test_blueprints.py @@ -73,21 +73,6 @@ class BlueprintsTest(unittest.TestCase): self.assertTrue("example-http-server" in output) self.assertTrue("Recipe example-http-server, version 0.0.1 saved." in output) - @unittest.skipUnless(os.path.exists("/run/weldr/api.socket"), "Test requires a running API server") - def test_diff(self): - """blueprints diff""" - # Get the oldest commit, it should be 2nd to last line - with captured_output() as (out, _): - rc = blueprints_changes("/run/weldr/api.socket", 0, ["example-http-server"], show_json=False) - output = out.getvalue().strip().splitlines() - first_commit = output[-2].split()[1] - - with captured_output() as (out, _): - rc = blueprints_diff("/run/weldr/api.socket", 0, ["example-http-server", first_commit, "HEAD"], show_json=False) - output = out.getvalue().strip() - self.assertTrue(rc == 0) - self.assertTrue("Changed Version" in output) - @unittest.skipUnless(os.path.exists("/run/weldr/api.socket"), "Test requires a running API server") def test_save_0(self): """blueprints save""" @@ -172,3 +157,20 @@ class BlueprintsTest(unittest.TestCase): """blueprints workspace""" rc = blueprints_push("/run/weldr/api.socket", 0, ["example-http-server.toml"], show_json=False) self.assertTrue(rc == 0) + + # XXX MUST COME LAST + # XXX which is what _z_ ensures + @unittest.skipUnless(os.path.exists("/run/weldr/api.socket"), "Test requires a running API server") + def test_z_diff(self): + """blueprints diff""" + # Get the oldest commit, it should be 2nd to last line + with captured_output() as (out, _): + rc = blueprints_changes("/run/weldr/api.socket", 0, ["example-http-server"], show_json=False) + output = out.getvalue().strip().splitlines() + first_commit = output[-2].split()[1] + + with captured_output() as (out, _): + rc = blueprints_diff("/run/weldr/api.socket", 0, ["example-http-server", first_commit, "HEAD"], show_json=False) + output = out.getvalue().strip() + self.assertTrue(rc == 0) + self.assertTrue("Changed Version" in output) diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index 923f123d..5110c7d7 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -141,6 +141,13 @@ class ServerTestCase(unittest.TestCase): data = json.loads(resp.data) self.assertEqual(data, list_dict) + # Make sure limit=0 still returns the correct total + resp = self.server.get("/api/v0/blueprints/list?limit=0") + data = json.loads(resp.data) + self.assertEqual(data["limit"], 0) + self.assertEqual(data["offset"], 0) + self.assertEqual(data["total"], list_dict["total"]) + def test_03_blueprints_info_1(self): """Test the /api/v0/blueprints/info route with one blueprint""" info_dict_1 = {"changes":[{"changed":False, "name":"example-http-server"}], @@ -214,6 +221,13 @@ class ServerTestCase(unittest.TestCase): self.assertEqual(data["blueprints"][0]["name"], "example-http-server") self.assertEqual(len(data["blueprints"][0]["changes"]), 1) + # Make sure limit=0 still returns the correct total + resp = self.server.get("/api/v0/blueprints/changes/example-http-server?limit=0") + data = json.loads(resp.data) + self.assertEqual(data["limit"], 0) + self.assertEqual(data["offset"], 0) + self.assertEqual(data["blueprints"][0]["total"], 1) + def test_04a_blueprints_diff_empty_ws(self): """Test the /api/v0/diff/NEWEST/WORKSPACE with empty workspace""" resp = self.server.get("/api/v0/blueprints/diff/example-glusterfs/NEWEST/WORKSPACE") @@ -515,6 +529,13 @@ class ServerTestCase(unittest.TestCase): projects = data.get("projects") self.assertEqual(len(projects) > 10, True) + expected_total = data["total"] + + # Make sure limit=0 still returns the correct total + resp = self.server.get("/api/v0/projects/list?limit=0") + data = json.loads(resp.data) + self.assertEqual(data["total"], expected_total) + def test_projects_info(self): """Test /api/v0/projects/info/""" resp = self.server.get("/api/v0/projects/info/bash") @@ -676,6 +697,8 @@ class ServerTestCase(unittest.TestCase): self.assertEqual(len(modules) > 10, True) self.assertEqual(modules[0]["group_type"], "rpm") + expected_total = data["total"] + resp = self.server.get("/api/v0/modules/list/d*") data = json.loads(resp.data) self.assertNotEqual(data, None) @@ -683,6 +706,12 @@ class ServerTestCase(unittest.TestCase): self.assertEqual(len(modules) > 0, True) self.assertEqual(modules[0]["name"].startswith("d"), True) + # Make sure limit=0 still returns the correct total + resp = self.server.get("/api/v0/modules/list?limit=0") + data = json.loads(resp.data) + self.assertNotEqual(data, None) + self.assertEqual(data["total"], expected_total) + def test_modules_info(self): """Test /api/v0/modules/info""" resp = self.server.get("/api/v0/modules/info/bash")