diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2016-10-31 12:56:38 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2016-11-08 09:14:26 +0000 |
commit | b3071ecf941d030092a33086c4d632ed88c52bcf (patch) | |
tree | 163e6e006ddc61811a516bb141934f918dd10486 /tests/unit/common/test_utils.py | |
parent | e80a6484956de102d14b2b42349ac1e90510cd82 (diff) |
Create a constants.py to manage constant variable consistently
JIRA: YARDSTICK-378
Change-Id: I527d4f60f2a2081730118bdbbea6c19fc093672f
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'tests/unit/common/test_utils.py')
-rw-r--r-- | tests/unit/common/test_utils.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py index 002d0494c..a64c1f1ab 100644 --- a/tests/unit/common/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -83,6 +83,33 @@ class ImportModulesFromPackageTestCase(unittest.TestCase): mock_importutils.import_module.assert_called_with('bar.baz') +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): + file_path = 'config_sample.yaml' + file_path = self._get_file_abspath(file_path) + args = 'releng.file' + self.assertIsNone(utils.get_para_from_yaml(file_path, args)) + + def test_get_para_from_yaml_para_exists(self): + file_path = 'config_sample.yaml' + file_path = 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)) + + def _get_file_abspath(self, filename): + curr_path = os.path.dirname(os.path.abspath(__file__)) + file_path = os.path.join(curr_path, filename) + return file_path + + def main(): unittest.main() |