aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cli_test.py
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-04 10:03:03 +0800
committerzhifeng jiang <jiang.zhifeng@zte.com.cn>2016-09-08 11:23:35 +0000
commit6612d7c20e329cd5b133a41a6b35c67539f3369b (patch)
tree9d977adb46d347b980b0f49756e5607907d346fe /tests/cli_test.py
parentcf0b4338abd0dc4f8a835440db7c662a37e92911 (diff)
Remove os environment in driver.py so that it can be called by restful server
modification: Change os environments to parameters in driver.py Pass the parameters in cli.py and arg_handler.py JIRA:QTIP-97 Change-Id: Id67acb7e0ac46fa9e0e32481e947055b6d37dd95 Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'tests/cli_test.py')
-rw-r--r--tests/cli_test.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/cli_test.py b/tests/cli_test.py
index f9861dee..fe05327d 100644
--- a/tests/cli_test.py
+++ b/tests/cli_test.py
@@ -1,5 +1,6 @@
import pytest
import mock
+import os
from func.cli import cli
@@ -15,8 +16,11 @@ class TestClass:
'test'], "Test File Does not exist in test_list")
])
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()
resout, reserr = capfd.readouterr()
assert expected in resout
@@ -24,11 +28,14 @@ class TestClass:
(['-l',
'zte-pod1',
'-f',
- 'storage'], [('./test_cases/zte-pod1/storage/fio_bm.yaml'),
- ('./test_cases/zte-pod1/storage/fio_vm.yaml')])
+ 'storage'], [('fuel', '/home', './test_cases/zte-pod1/storage/fio_bm.yaml'),
+ ('fuel', '/home', './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):
+ k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'})
+ k.start()
cli(test_input)
- call_list = map(lambda x: mock_args_handler.call_args_list[x][0][0], range(len(expected)))
+ k.stop()
+ call_list = map(lambda x: mock_args_handler.call_args_list[x][0], range(len(expected)))
assert sorted(call_list) == sorted(expected)