summaryrefslogtreecommitdiffstats
path: root/legacy/tests/cli_test.py
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-01-08 09:48:31 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-01-11 15:14:16 +0800
commit23b627df622eeafafa215ce19764310c1d55dd55 (patch)
treed92c4c9b8a50a03461a40d2a2aba67bc7312041a /legacy/tests/cli_test.py
parent23f48e46a46976ae6f6d97aea11440e6a8b63121 (diff)
Reorganize the project folders
Code from Brahmaputra is no longer maintained, including: - docker - playbooks - scripts - utils They are moved to legacy folder to avoid unnecessary confusion to new developers. Change-Id: Ia50383ca5c3bd82571eb7b2184e7f83e264ff8a7 Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'legacy/tests/cli_test.py')
-rw-r--r--legacy/tests/cli_test.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/legacy/tests/cli_test.py b/legacy/tests/cli_test.py
new file mode 100644
index 00000000..0f3e4158
--- /dev/null
+++ b/legacy/tests/cli_test.py
@@ -0,0 +1,44 @@
+import pytest
+import mock
+import os
+from qtip.utils.cli import Cli
+from os.path import expanduser
+
+
+@pytest.mark.skip("TODO(yujunz) recover test after refactoring")
+class TestClass:
+ @pytest.mark.parametrize("test_input, expected", [
+ (['-l',
+ 'zte',
+ '-f',
+ 'compute'], "You have specified a lab that is not present under benchmarks/testplan"),
+ (['-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/testplan/default/storage/fio_bm.yaml'),
+ ('fuel', '/home', 'benchmarks/testplan/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)