aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-09-27 13:33:13 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-27 13:33:13 +0000
commit2ac37969827ee55a32dc5fdd337cdeebf0bceb46 (patch)
treec23b8d3820cfec24b7395b601a874973051239e9 /tests
parent2d705000187bc5a786cff591966b0b6907105856 (diff)
parent1a2b55736da4d18758f81444933181e380202f60 (diff)
Merge "code refactor: run_qtip.sh"
Diffstat (limited to 'tests')
-rw-r--r--tests/fetchimg_test.py34
-rw-r--r--tests/spawn_vm_test.py13
2 files changed, 1 insertions, 46 deletions
diff --git a/tests/fetchimg_test.py b/tests/fetchimg_test.py
deleted file mode 100644
index 5d482567..00000000
--- a/tests/fetchimg_test.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import mock
-from func.fetchimg import FetchImg
-
-
-class TestClass:
- @mock.patch('func.fetchimg.os')
- @mock.patch('func.fetchimg.os.path')
- def test_fetch_img_success(self, mock_path, mock_os):
- mock_os.system.return_value = True
- mock_path.isfile.return_value = True
- img = FetchImg()
- img.download()
-
- @mock.patch('func.fetchimg.time')
- @mock.patch('func.fetchimg.os.system')
- @mock.patch('func.fetchimg.os.path')
- def test_fetch_img_fail(self, mock_path, mock_system, mock_time):
- img = FetchImg()
- mock_system.return_value = True
- mock_path.isfile.side_effect = [False, False, True]
- img.download()
- assert mock_time.sleep.call_count == 2
-
- @mock.patch('func.fetchimg.time')
- @mock.patch('func.fetchimg.os.system')
- @mock.patch('func.fetchimg.os.path')
- def test_fetch_temp_success(self, mock_path, mock_system, mock_time):
- img = FetchImg()
- mock_system.return_value = True
- mock_path.isfile.side_effect = [True]
- img.download()
- filepath = './Temp_Img/QTIP_CentOS.qcow2'
- imgstorepath = "/home/opnfv/imgstore/QTIP_CentOS.qcow2"
- mock_system.assert_called_with("ln -s %s %s" % (imgstorepath, filepath))
diff --git a/tests/spawn_vm_test.py b/tests/spawn_vm_test.py
index eb843ad9..b22745d7 100644
--- a/tests/spawn_vm_test.py
+++ b/tests/spawn_vm_test.py
@@ -10,15 +10,6 @@ class KeystoneMock(MagicMock):
v2_0 = Mock()
-class ImageMock(MagicMock):
- name = 'QTIP_CentOS'
-
-
-class ImagesMock(MagicMock):
- def list(self):
- return [ImageMock()]
-
-
class StackMock(MagicMock):
status = 'COMPLETE'
outputs = [{'output_key': 'availability_instance_1',
@@ -55,13 +46,11 @@ class TestClass:
@mock.patch('func.spawn_vm.FetchImg')
@mock.patch('func.spawn_vm.create_zones')
@mock.patch('func.spawn_vm.client', autospec=True)
- @mock.patch('func.spawn_vm.glanceclient', autospec=True)
@mock.patch('func.spawn_vm.keystoneclient.v2_0', autospec=True)
@mock.patch('func.spawn_vm.heatclient.client', autospec=True)
- def test_create_zones_success(self, mock_heat, mock_keystone, mock_glance,
+ def test_create_zones_success(self, mock_heat, mock_keystone,
mock_nova_client, mock_zone, mock_fetch,
mock_setup, test_input, expected):
- mock_glance.Client.return_value = Mock(images=ImagesMock())
mock_nova_client.Client.return_value = Mock()
mock_heat.Client.return_value = Mock(stacks=HeatMock())
k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel'})