aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cli_test.py
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-09 13:17:14 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-09 13:17:14 +0000
commit3a987ca748287d250d7975a853222917f001469a (patch)
treebc5bb80397c015c37fb0c92b072b62cdbac02a15 /tests/cli_test.py
parent84d204b3a1e68238105f9fe6cd9b02591dde6ca6 (diff)
parent6612d7c20e329cd5b133a41a6b35c67539f3369b (diff)
Merge "Remove os environment in driver.py so that it can be called by restful server"
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)