summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/tests/test_volume_view.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/vio/vio/tests/test_volume_view.py b/vio/vio/tests/test_volume_view.py
index 556390b..b996994 100644
--- a/vio/vio/tests/test_volume_view.py
+++ b/vio/vio/tests/test_volume_view.py
@@ -99,3 +99,25 @@ class TestCreateListVolumeView(unittest.TestCase):
ret = self.view.get(
mock.Mock(query_params=[]), "vmware_nova", "tenant1")
self.assertEqual(200, 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_get_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]
+ ret = self.view.get(
+ mock.Mock(query_params=[]), "vmware_nova", "tenant1")
+ self.assertEqual(500, ret.status_code)