diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-04-11 10:47:23 +0800 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-04-11 10:47:23 +0800 |
commit | e988d527367b6073b9703a7497e6151d34c7f22b (patch) | |
tree | a9a08c0ef4dbd4d3c9fa851eccfdf7cc5317c426 /vio | |
parent | a95d7a201805edb593f35949bca2b50b976e3793 (diff) |
Add test_post_fail for CreateListVolumeView
Add test_post_fail
Change-Id: I5f77a1abec57ecb60ebd4a959ca4852b9d0ad6c2
Issue-ID: MULTICLOUD-199
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio/tests/test_volume_view.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/vio/vio/tests/test_volume_view.py b/vio/vio/tests/test_volume_view.py index 88c8f59..9d8395e 100644 --- a/vio/vio/tests/test_volume_view.py +++ b/vio/vio/tests/test_volume_view.py @@ -176,3 +176,28 @@ class TestCreateListVolumeView(unittest.TestCase): }""" ret = self.view.post(req, "vmware_nova", "tenant1") self.assertEqual(202, ret.status_code) + + @mock.patch.object(OperateVolume.OperateVolume, "get_vim_volumes") + @mock.patch.object(OperateVolume.OperateVolume, "get_vim_volume") + @mock.patch.object(extsys, "get_vim_by_id") + def test_post_fail(self, mock_getvim, mock_getvol, mock_getvols): + mock_getvim.return_value = { + "tenant": "tenant-id" + } + vol = mock.Mock() + vol.attachments = [] + vol.id = "vol-id" + vol.name = "vol-name" + vol.created_at = "create time" + vol.status = "ok" + vol.volume_type = "vmdk" + vol.size = 1 + vol.availability_zone = "nova" + mock_getvol.side_effect = [Exception("error")] + mock_getvols.return_value = [vol] + req = mock.Mock() + req.body = """{ + "name": "vol-name" + }""" + ret = self.view.post(req, "vmware_nova", "tenant1") + self.assertEqual(500, ret.status_code) |