diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-06-13 14:55:56 +0800 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-06-13 14:58:33 +0800 |
commit | 2482b242b5664e68a5d1f6f04b69c93ad7022681 (patch) | |
tree | b39d0e260d5bcfad440614723e3c910a3fd10ed9 | |
parent | 709787048e8ebba415b75348f2e7dc4703110d65 (diff) |
Add test_operate_server_stop
Add test_operate_server_stop
Change-Id: I51bba4d3fff33e52c00b1c0c5002d786b78dc46e
Issue-ID: MULTICLOUD-199
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r-- | vio/vio/tests/test_fake_nova_view.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vio/vio/tests/test_fake_nova_view.py b/vio/vio/tests/test_fake_nova_view.py index 34c58a6..feab23b 100644 --- a/vio/vio/tests/test_fake_nova_view.py +++ b/vio/vio/tests/test_fake_nova_view.py @@ -10,6 +10,7 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +import json import mock import unittest @@ -29,6 +30,9 @@ class TestFakeNovaServer(unittest.TestCase): def setUp(self): self.view = views.FakeNovaServer() + def tearDown(self): + fakeResponse.serverMapps[Server]['status'] = "ACTIVE" + @mock.patch.object(fakeResponse, "show_serverDetail") def test_get_server(self, mock_show_serverDetail): req = mock.Mock() @@ -67,6 +71,19 @@ class TestFakeNovaServer(unittest.TestCase): resp = self.view.get(req, "abcd") self.assertEqual(401, resp.status_code) + def test_operate_server_stop(self): + req = mock.Mock() + req.META = { + "HTTP_X_AUTH_TOKEN": Token + } + req.body = json.dumps({ + "os-stop": {} + }) + resp = self.view.post(req, "abcd", Server) + self.assertEqual(202, resp.status_code) + self.assertEqual( + "POWERING_OFF", fakeResponse.serverMapps[Server]['status']) + class TestFakeNovaHypervisors(unittest.TestCase): |