summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Ke <lokyse@163.com>2018-03-29 09:00:53 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-29 09:00:53 +0000
commitf63b9f21f24f9562654e31a169d5e4a830a92cdd (patch)
tree3689db1f8f554618225b7af75ed19787c8bede5a
parent2a770fe320f5c4386664310fa040ae75e202b9cb (diff)
parente483855c72427bde959b52c8e81932ce4f6abfd4 (diff)
Merge "Add test_post for CreateImageView"
-rw-r--r--vio/vio/tests/test_image_view.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/vio/vio/tests/test_image_view.py b/vio/vio/tests/test_image_view.py
index 968826f..112ee5a 100644
--- a/vio/vio/tests/test_image_view.py
+++ b/vio/vio/tests/test_image_view.py
@@ -69,3 +69,25 @@ class TestCreateListImagesView(unittest.TestCase):
resp = self.view.get(
mock.Mock(query_params=[]), "vmware_nova", "tenant1")
self.assertEqual(200, resp.status_code)
+
+ @mock.patch.object(OperateImage.OperateImage, "get_vim_image")
+ @mock.patch.object(OperateImage.OperateImage, "get_vim_images")
+ @mock.patch.object(extsys, "get_vim_by_id")
+ def test_post(self, mock_getvim, mock_getimgs, mock_getimg):
+ mock_getvim.return_value = {
+ "tenant": "tenant-id"
+ }
+ img = mock.Mock()
+ img.id = "image-id"
+ img.name = "image-a"
+ img.to_dict.return_value = {
+ "id": "image-id",
+ "name": "image-a"
+ }
+ mock_getimgs.return_value = [img]
+ req = mock.Mock()
+ req.body = """{
+ "name": "image-a"
+ }"""
+ resp = self.view.post(req, "vmware_nova", "tenant1")
+ self.assertEqual(200, resp.status_code)