aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cli_test.py
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-08-20 16:29:26 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-08-21 14:23:13 +0800
commit9b23320f77639f07d2156a4add18fb2f99771520 (patch)
tree3593b673535bd109fc7031eeb7f00848c5c8b0fb /tests/cli_test.py
parente0482d626cedfb1f30712e82df288454af65c76c (diff)
Code refactoring cli.py so that it can be reused by restful server.
modification: Move function in cli.py to args_handler.py Add unit test for args_handler.py Add unit test for cli.py Delete print in driver.py to pass unit test JIRA:QTIP-99 Change-Id: Ib670d7dff494f3e04cdbe1de5c247d382b1052c1 Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'tests/cli_test.py')
-rw-r--r--tests/cli_test.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/cli_test.py b/tests/cli_test.py
index bd31d987..f9861dee 100644
--- a/tests/cli_test.py
+++ b/tests/cli_test.py
@@ -1,4 +1,5 @@
import pytest
+import mock
from func.cli import cli
@@ -18,3 +19,16 @@ class TestClass:
cli(test_input)
resout, reserr = capfd.readouterr()
assert expected in resout
+
+ @pytest.mark.parametrize("test_input, expected", [
+ (['-l',
+ 'zte-pod1',
+ '-f',
+ 'storage'], [('./test_cases/zte-pod1/storage/fio_bm.yaml'),
+ ('./test_cases/zte-pod1/storage/fio_vm.yaml')])
+ ])
+ @mock.patch('func.cli.args_handler.prepare_and_run_benchmark')
+ def test_cli_successful(self, mock_args_handler, test_input, expected):
+ cli(test_input)
+ call_list = map(lambda x: mock_args_handler.call_args_list[x][0][0], range(len(expected)))
+ assert sorted(call_list) == sorted(expected)