From 6612d7c20e329cd5b133a41a6b35c67539f3369b Mon Sep 17 00:00:00 2001 From: "zhifeng.jiang" Date: Sun, 4 Sep 2016 10:03:03 +0800 Subject: 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 --- tests/cli_test.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests/cli_test.py') 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) -- cgit 1.2.3-korg