summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-07-08 11:03:22 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-07-08 11:03:22 +0800
commit3a4f1304b228c559536f7c0d7fa052d7e61b6a56 (patch)
treee30d2887a467fcc33ca41d743b8dae2c91f7cbfa /tests
parent5dbf3c4e2f6ef48676de10b4394de4a45456810d (diff)
Add some UT test cases and fix pep8 errors for fetchimg
JIRA:QTIP-89 Change-Id: I623cd6e48d90996b0199f9b31f86c8844b4d5ceb Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/fetchimg_test.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/fetchimg_test.py b/tests/fetchimg_test.py
new file mode 100644
index 00000000..683c9701
--- /dev/null
+++ b/tests/fetchimg_test.py
@@ -0,0 +1,22 @@
+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, True]
+ img.download()
+ assert mock_time.sleep.call_count == 2