summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-04-11 10:26:35 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-04-11 10:29:20 +0800
commit4f60ae1f57dd212fdd18132deb2d762f8299f2ac (patch)
tree2d0c7354b13086a07707b7c9bdf1821b86c06cb0 /vio
parent4d68b591fcb1b677f94419b2440b8e03515fa78f (diff)
Add test_get for CreateListVolumeView
Add test_get Change-Id: I486e85f042bceb23bbf88927472d0f1313fbc37e 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.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/vio/vio/tests/test_volume_view.py b/vio/vio/tests/test_volume_view.py
index 1cb8354..556390b 100644
--- a/vio/vio/tests/test_volume_view.py
+++ b/vio/vio/tests/test_volume_view.py
@@ -71,3 +71,31 @@ class TestGetDeleteVolumeView(unittest.TestCase):
mock_delvol.side_effect = [Exception("error")]
ret = self.view.delete(mock.Mock(), "vmware_nova", "tenant1", "vol-1")
self.assertEqual(500, ret.status_code)
+
+
+class TestCreateListVolumeView(unittest.TestCase):
+
+ def setUp(self):
+ self.view = views.CreateListVolumeView()
+
+ @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(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.return_value = vol
+ mock_getvols.return_value = [vol]
+ ret = self.view.get(
+ mock.Mock(query_params=[]), "vmware_nova", "tenant1")
+ self.assertEqual(200, ret.status_code)