aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-07-28 07:10:40 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-07-28 07:10:40 +0800
commitdd0a00b503f1d6e8d43d30646ffc2642bb04fe93 (patch)
treeae8a3c77df27d346491052248058691c875d273a /tests
parent9197285af7b9ffe49eb22902477c559cef35b43f (diff)
Solving the facing problems when enable unit test
modification: Delete and let git ignore the files which are generated by Qtip running time every time. Add the one more UT for the code "Use local QTIP CentOS.qcow2 img file" Change-Id: Ida891c421306274241d1c4581dd5e274e3bdb0fe Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/fetchimg_test.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/fetchimg_test.py b/tests/fetchimg_test.py
index 683c9701..5d482567 100644
--- a/tests/fetchimg_test.py
+++ b/tests/fetchimg_test.py
@@ -17,6 +17,18 @@ class TestClass:
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, 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))