From e483855c72427bde959b52c8e81932ce4f6abfd4 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Tue, 27 Mar 2018 15:30:05 -0700 Subject: Add test_post for CreateImageView Add test_post Change-Id: Ic69ace33551a1aac723d89efea96cece88e824d4 Issue-ID: MULTICLOUD-199 Signed-off-by: Ethan Lynn --- vio/vio/tests/test_image_view.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'vio') 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) -- cgit 1.2.3-korg