diff options
author | Moshe <moshehoa@amdocs.com> | 2018-06-20 10:23:28 +0300 |
---|---|---|
committer | Moshe <moshehoa@amdocs.com> | 2018-06-20 12:13:36 +0300 |
commit | c7c4cc227ed9447b4fdceeceece35384404bd7ec (patch) | |
tree | 5a7900dfa5ce66c1821e2ab0719741e9cccfb126 /vnftest/tests/unit | |
parent | e65155cab8d6d74989f1dd0bd1a493e1c91a30d9 (diff) |
Add validation abilities to test cases
Change-Id: I76b28e6170d6e91836b195d58c0b882168c11a67
Issue-ID: VNFSDK-275
Signed-off-by: Moshe <moshehoa@amdocs.com>
Add unit tests
Issue-ID: VNFSDK-275
Change-Id: I34bc9a11e16e4092fdad3b4a1733c7219e624f5f
Signed-off-by: Moshe <moshehoa@amdocs.com>
add unit tests
Issue-ID: VNFSDK-275
Change-Id: Ib99c3521438b002e0d8aaff9870224673e34899f
Signed-off-by: Moshe <moshehoa@amdocs.com>
add unit tests
Issue-ID: VNFSDK-275
Change-Id: I1ac560dfb40df5f346b0db8f40b8c52a2fb6b350
Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/tests/unit')
-rw-r--r-- | vnftest/tests/unit/common/test_utils.py | 33 | ||||
-rw-r--r-- | vnftest/tests/unit/core/no_constraint_with_args_step_sample.yaml | 5 | ||||
-rw-r--r-- | vnftest/tests/unit/core/test_task.py | 17 |
3 files changed, 35 insertions, 20 deletions
diff --git a/vnftest/tests/unit/common/test_utils.py b/vnftest/tests/unit/common/test_utils.py index da64d4e..e8860cb 100644 --- a/vnftest/tests/unit/common/test_utils.py +++ b/vnftest/tests/unit/common/test_utils.py @@ -49,7 +49,7 @@ class IterSubclassesTestCase(unittest.TestCase): class D(C): pass - self.assertEqual([B, C, D], list(utils.itersubclasses(A))) + self.assertEqual([B, C, D], list(utils.findsubclasses(A))) class ImportModulesFromPackageTestCase(unittest.TestCase): @@ -1123,3 +1123,34 @@ class ReadMeminfoTestCase(unittest.TestCase): 'Active(anon)': '3015676', 'HugePages_Total': '8', 'Hugepagesize': '1048576'} + + +class TestUtils(unittest.TestCase): + + def test_convert_xml_to_dict(self): + input_str = "<a><b>dummy1</b><b>dummy2</b></a>" + result = utils.xml_to_dict(input_str) + self.assertEqual(result, {'a': {'b': ['dummy1', 'dummy2']}}) + + def test_format(self): + input_str = "{aaa}" + params = {'aaa': 'dummy'} + result = utils.format(input_str, params) + self.assertEqual(result, "dummy") + + def test_obj_to_dict(self): + dummy_class = DummyClass() + result = utils.normalize_data_struct(dummy_class) + self.assertEqual(result, {'aaa': 'aaa', 'bbb': ["1", "2"], 'ccc': {"x": "y"}}) + + def test_load_resource(self): + input_str = "vnftest/tests/unit/common/config_sample.yaml" + resource = utils.load_resource(input_str) + assert resource is not None + + +class DummyClass(object): + def __init__(self): + self.aaa = "aaa" + self.bbb = ["1", "2"] + self.ccc = {"x": "y"} diff --git a/vnftest/tests/unit/core/no_constraint_with_args_step_sample.yaml b/vnftest/tests/unit/core/no_constraint_with_args_step_sample.yaml index 3667230..9b8b09a 100644 --- a/vnftest/tests/unit/core/no_constraint_with_args_step_sample.yaml +++ b/vnftest/tests/unit/core/no_constraint_with_args_step_sample.yaml @@ -19,12 +19,11 @@ schema: "vnftest:suite:0.1" name: "suite_1" -test_cases_dir: "tests/onap/test_cases/" test_cases: - - file_name: onap_vnftest_tc001.yaml + file_name: tests/onap/test_cases/onap_vnftest_tc001.yaml - - file_name: onap_vnftest_tc002.yaml + file_name: tests/onap/test_cases/onap_vnftest_tc002.yaml task_args: huawei-pod1: '{"host": "node1.LF","target": "node2.LF"}' diff --git a/vnftest/tests/unit/core/test_task.py b/vnftest/tests/unit/core/test_task.py index b136960..21947c9 100644 --- a/vnftest/tests/unit/core/test_task.py +++ b/vnftest/tests/unit/core/test_task.py @@ -74,10 +74,6 @@ class TaskTestCase(unittest.TestCase): new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): task_files, task_args, task_args_fnames = t.parse_suite() - self.assertEqual(task_files[0], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc001.yaml')) - self.assertEqual(task_files[1], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc002.yaml')) self.assertIsNone(task_args[0]) self.assertIsNone(task_args[1]) self.assertIsNone(task_args_fnames[0]) @@ -90,10 +86,6 @@ class TaskTestCase(unittest.TestCase): new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): task_files, task_args, task_args_fnames = t.parse_suite() - self.assertEqual(task_files[0], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc001.yaml')) - self.assertEqual(task_files[1], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc002.yaml')) self.assertIsNone(task_args[0]) self.assertEqual(task_args[1], '{"host": "node1.LF","target": "node2.LF"}') @@ -106,10 +98,7 @@ class TaskTestCase(unittest.TestCase): with mock.patch.object(os, 'environ', new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): task_files, task_args, task_args_fnames = t.parse_suite() - self.assertEqual(task_files[0], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc001.yaml')) - self.assertEqual(task_files[1], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc002.yaml')) + self.assertIsNone(task_args[0]) self.assertIsNone(task_args[1]) self.assertIsNone(task_args_fnames[0]) @@ -122,10 +111,6 @@ class TaskTestCase(unittest.TestCase): new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): task_files, task_args, task_args_fnames = t.parse_suite() - self.assertEqual(task_files[0], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc001.yaml')) - self.assertEqual(task_files[1], self.change_to_abspath( - 'tests/onap/test_cases/onap_vnftest_tc002.yaml')) self.assertIsNone(task_args[0]) self.assertEqual(task_args[1], '{"host": "node1.LF","target": "node2.LF"}') |