diff options
author | Jing Lu <lvjing5@huawei.com> | 2017-04-06 07:01:18 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-04-06 07:01:18 +0000 |
commit | 9c7086ce2f23aa4dd47373208651ff1e560c41de (patch) | |
tree | d9b0fbe7c0b767035ebb6d9cfd9c14b3d9a7da02 /tests/unit | |
parent | c5a35bcde80df0dd367e40b9acd7f941b33dc4bc (diff) | |
parent | 221f4482bab3361cdb69161147e4d32d098d9a43 (diff) |
Merge "Yardstick virtualenv support" into stable/danube
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/common/test_utils.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py index 267c71312..8f52b53b0 100644 --- a/tests/unit/common/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -87,24 +87,21 @@ class ImportModulesFromPackageTestCase(unittest.TestCase): class GetParaFromYaml(unittest.TestCase): - def test_get_para_from_yaml_file_not_exist(self): - file_path = '/etc/yardstick/hello.yaml' - args = 'hello.world' - para = utils.get_para_from_yaml(file_path, args) - self.assertIsNone(para) - - def test_get_para_from_yaml_para_not_found(self): + @mock.patch('yardstick.common.utils.os.environ.get') + def test_get_param_para_not_found(self, get_env): file_path = 'config_sample.yaml' - file_path = self._get_file_abspath(file_path) + get_env.return_value = self._get_file_abspath(file_path) args = 'releng.file' - self.assertIsNone(utils.get_para_from_yaml(file_path, args)) + default = 'hello' + self.assertTrue(utils.get_param(args, default), default) - def test_get_para_from_yaml_para_exists(self): + @mock.patch('yardstick.common.utils.os.environ.get') + def test_get_param_para_exists(self, get_env): file_path = 'config_sample.yaml' - file_path = self._get_file_abspath(file_path) + get_env.return_value = self._get_file_abspath(file_path) args = 'releng.dir' para = '/home/opnfv/repos/releng' - self.assertEqual(para, utils.get_para_from_yaml(file_path, args)) + self.assertEqual(para, utils.get_param(args)) def _get_file_abspath(self, filename): curr_path = os.path.dirname(os.path.abspath(__file__)) |