From c8a462f963da37832aea2f232d3668e8ece0b8bd Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 7 Jun 2024 13:27:02 +0200 Subject: [PATCH] Fix test --- test/integration/TestREST.py | 7 ------- test/integration/TestREST_JSON.py | 7 ------- test/unit/REST.py | 12 ++++++++++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/test/integration/TestREST.py b/test/integration/TestREST.py index 65bb4fec..c7dd8c42 100755 --- a/test/integration/TestREST.py +++ b/test/integration/TestREST.py @@ -139,13 +139,6 @@ def test_05_version(self): self.assertEqual( resp.text, version, msg="Incorrect version. Expected %s, obtained: %s" % (version, resp.text)) - def test_07_index(self): - resp = self.create_request("GET", "/") - self.assertEqual(resp.status_code, 200, - msg="ERROR getting IM index:" + resp.text) - res = json.loads(resp.text) - self.assertEqual(res['openapi'], '3.0.0') - def test_10_list(self): resp = self.create_request("GET", "/infrastructures") self.assertEqual(resp.status_code, 200, diff --git a/test/integration/TestREST_JSON.py b/test/integration/TestREST_JSON.py index 032503e6..30b26124 100755 --- a/test/integration/TestREST_JSON.py +++ b/test/integration/TestREST_JSON.py @@ -131,13 +131,6 @@ def wait_inf_state(self, state, timeout, incorrect_states=None, vm_ids=None): return all_ok - def test_10_index(self): - resp = self.create_request("GET", "/") - self.assertEqual(resp.status_code, 200, - msg="ERROR getting IM index:" + resp.text) - res = json.loads(resp.text) - self.assertEqual(res['openapi'], '3.0.0') - def test_20_create(self): radl = read_file_as_string('../files/test_simple.json') resp = self.create_request("POST", "/infrastructures", diff --git a/test/unit/REST.py b/test/unit/REST.py index 56b24ba4..5f39f371 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -570,8 +570,16 @@ def test_GeVersion(self): def test_Index(self): res = self.client.get('/') - self.assertEqual(res.json['openapi'], '3.0.0') - self.assertEqual(res.json['servers'][0]['url'], 'http://localhost/') + self.assertEqual(res.status_code, 302) + self.assertEqual(res.headers['Location'], '/api/docs') + res = self.client.get('http://localhost/api/docs/') + self.assertEqual(res.status_code, 200) + self.assertIn("Swagger UI", res.text) + self.assertIn('"url": "/swagger.json"', res.text) + res = self.client.get('/swagger.json') + self.assertEqual(res.status_code, 200) + self.assertEqual(res.json["openapi"], "3.0.0") + @patch("IM.InfrastructureManager.InfrastructureManager.CreateDiskSnapshot") def test_CreateDiskSnapshot(self, CreateDiskSnapshot):