From 9b23320f77639f07d2156a4add18fb2f99771520 Mon Sep 17 00:00:00 2001 From: "zhifeng.jiang" Date: Sat, 20 Aug 2016 16:29:26 +0800 Subject: 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 --- tests/cli_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/cli_test.py') 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) -- cgit 1.2.3-korg