diff options
author | Liang Ke <lokyse@163.com> | 2018-07-04 03:07:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-07-04 03:07:42 +0000 |
commit | 32d538cfb834bc15746a17f057978ba997bbcb40 (patch) | |
tree | 3c40f83ae2f7f26709238e9459cdf3b1f65ad6cc /vio | |
parent | b9f979305f530155d25a70de5d62f791c2850ed8 (diff) | |
parent | 95616621e4b0e1bd65f5a3f1f0412c859105c6a5 (diff) |
Merge changes from topic 'ut3'
* changes:
Add test_create_server
Add test_get_flavors_detail
Add TestFakeNovaHypervisorUptime
Add test_operate_server_unsupport
Add test_operate_server_reboot
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio/tests/test_fake_nova_view.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/vio/vio/tests/test_fake_nova_view.py b/vio/vio/tests/test_fake_nova_view.py index b97435a..f07aa47 100644 --- a/vio/vio/tests/test_fake_nova_view.py +++ b/vio/vio/tests/test_fake_nova_view.py @@ -139,6 +139,62 @@ class TestFakeNovaServer(unittest.TestCase): self.assertEqual( "ACTIVE", fakeResponse.serverMapps[Server]['status']) + def test_operate_server_reboot(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + req.body = json.dumps({ + "reboot": {} + }) + resp = self.view.post(req, "abcd", Server) + self.assertEqual(202, resp.status_code) + self.assertEqual( + "REBOOTING", fakeResponse.serverMapps[Server]['status']) + + def test_operate_server_unsupport(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + req.body = json.dumps({ + "invalid": {} + }) + resp = self.view.post(req, "abcd", Server) + self.assertEqual(405, resp.status_code) + + def test_create_server(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + req.body = json.dumps({ + "server": { + "name": "new_name" + } + }) + resp = self.view.post(req, "abcd") + self.assertEqual(202, resp.status_code) + server_id = resp.data['server']['id'] + self.assertEqual( + "BUILDING", fakeResponse.serverMapps[server_id]['status']) + self.assertEqual( + "new_name", fakeResponse.serverMapps[server_id]['name']) + + +class TestFakeNovaHypervisorUptime(unittest.TestCase): + + def setUp(self): + self.view = views.FakeNovaHypervisorsUptime() + + def test_get_hypervisor_uptime(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + resp = self.view.get(req, "tenant1", "hypervisor1") + self.assertEqual(200, resp.status_code) + class TestFakeNovaHypervisors(unittest.TestCase): @@ -211,6 +267,15 @@ class TestFakeFlavorDetail(unittest.TestCase): resp = self.view.get(req, "abcd", "1234") self.assertEqual(200, resp.status_code) + def test_get_flavors_detail(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + resp = self.view.get(req, "abcd", "detail") + self.assertEqual(200, resp.status_code) + self.assertEqual(6, len(resp.data["flavors"])) + class TestFakeFlavorList(unittest.TestCase): |