summaryrefslogtreecommitdiffstats
path: root/tests/unit/utils/cli_test.py
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-11-17 13:52:03 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2016-11-21 10:36:52 +0800
commit539405270b57a5ee7409a164a38b9fdb0b3624e7 (patch)
treec8f9a6fd5d61b8060802ec06bba5f9c94fe66bcb /tests/unit/utils/cli_test.py
parentcaa171ac3796bbeacfdac0939713eedfad85e3c3 (diff)
Architecture evolution skeleton
- benchmarks will be driven by qtip.runner - qtip.runner is used by both qtip.cli and qtip.api - unit test for each module will be placed under tests/unit - functional tests will be moved to tests/functional - data as testing sample will be moved to tests/data NOTE: this patch moves files only, it may fails many tests. To be followed up in next step. JIRA: QTIP-148 Change-Id: I27e8169a74783970a1f7818456eb76a7311fb60c Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'tests/unit/utils/cli_test.py')
-rw-r--r--tests/unit/utils/cli_test.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unit/utils/cli_test.py b/tests/unit/utils/cli_test.py
new file mode 100644
index 00000000..86dd6b98
--- /dev/null
+++ b/tests/unit/utils/cli_test.py
@@ -0,0 +1,43 @@
+import pytest
+import mock
+import os
+from qtip.utils.cli import Cli
+from os.path import expanduser
+
+
+class TestClass:
+ @pytest.mark.parametrize("test_input, expected", [
+ (['-l',
+ 'zte',
+ '-f',
+ 'compute'], "You have specified a lab that is not present under benchmarks/test_plan"),
+ (['-l',
+ 'default',
+ '-f',
+ 'test'], "This suite file test doesn't exist under benchmarks/suite/")
+ ])
+ def test_cli_error(self, capfd, test_input, expected):
+ k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})
+ with pytest.raises(SystemExit):
+ k.start()
+ Cli(test_input)
+ k.stop()
+ with open(expanduser('~') + "/qtip/logs/cli.log", "r") as file:
+ data = file.read()
+ assert expected in data
+
+ @pytest.mark.parametrize("test_input, expected", [
+ (['-l',
+ 'default',
+ '-f',
+ 'storage'], [('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_bm.yaml'),
+ ('fuel', '/home', 'benchmarks/test_plan/default/storage/fio_vm.yaml')])
+ ])
+ @mock.patch('qtip.utils.cli.args_handler.prepare_and_run_benchmark')
+ def test_cli_successful(self, mock_args_handler, test_input, expected):
+ k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})
+ k.start()
+ Cli(test_input)
+ k.stop()
+ call_list = map(lambda x: mock_args_handler.call_args_list[x][0], range(len(expected)))
+ assert sorted(call_list) == sorted(expected)