diff options
-rw-r--r-- | dovetail/tests/__init__.py | 0 | ||||
-rw-r--r-- | dovetail/tests/unit/__init__.py | 0 | ||||
-rw-r--r-- | dovetail/tests/unit/test_parser.py | 57 | ||||
-rw-r--r-- | dovetail/tests/unit/test_testcase.yaml | 10 |
4 files changed, 67 insertions, 0 deletions
diff --git a/dovetail/tests/__init__.py b/dovetail/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/dovetail/tests/__init__.py diff --git a/dovetail/tests/unit/__init__.py b/dovetail/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/dovetail/tests/unit/__init__.py diff --git a/dovetail/tests/unit/test_parser.py b/dovetail/tests/unit/test_parser.py new file mode 100644 index 00000000..5b003d1a --- /dev/null +++ b/dovetail/tests/unit/test_parser.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# lingui.zeng@huawei.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# +""" +Test 'parser' module + +""" + +import logging +import os +import unittest + +import yaml + +import dovetail.parser as dovetail_parser + + +class TestParser(unittest.TestCase): + + test_path = os.path.dirname(os.path.realpath(__file__)) + + def setUp(self): + """Test case setup""" + logging.disable(logging.CRITICAL) + + def test_parser_cmd(self): + """Test whether the command is correctly parsed.""" + mock_cmd = "python /functest/ci/run_tests.py -t {{script_testcase}} -r" + with open(os.path.join(self.test_path, 'test_testcase.yaml')) as f: + mock_testcase_yaml = yaml.safe_load(f) + MockTestcase = type('Testcase', (object,), {}) + mock_testcase = MockTestcase() + mock_testcase.testcase = mock_testcase_yaml.values()[0] + output = dovetail_parser.Parser.parse_cmd(mock_cmd, mock_testcase) + expected_output = ("python /functest/ci/run_tests.py -t " + "tempest_smoke_serial -r") + self.assertEqual(expected_output, output) + + def test_parser_cmd_fail(self): + """Test whether the command is correctly parsed.""" + mock_cmd = "python /functest/ci/run_tests.py -t {{script_testcase}} -r" + mock_testcase_yaml = {} + MockTestcase = type('Testcase', (object,), {}) + mock_testcase = MockTestcase() + mock_testcase.testcase = mock_testcase_yaml.values() + output = dovetail_parser.Parser.parse_cmd(mock_cmd, mock_testcase) + expected_output = ("python /functest/ci/run_tests.py -t " + "None -r") + self.assertEqual(expected_output, output) + +if __name__ == '__main__': + unittest.main() diff --git a/dovetail/tests/unit/test_testcase.yaml b/dovetail/tests/unit/test_testcase.yaml new file mode 100644 index 00000000..1b03262f --- /dev/null +++ b/dovetail/tests/unit/test_testcase.yaml @@ -0,0 +1,10 @@ +dovetail.ipv6.tc001: + name: dovetail.ipv6.tc001 + objective: VIM ipv6 operations, to create/delete network, port and subnet in bulk operation + scripts: + type: functest + testcase: tempest_smoke_serial + sub_testcase_list: + - tempest.api.network.test_networks.BulkNetworkOpsIpV6Test.test_bulk_create_delete_network + - tempest.api.network.test_networks.BulkNetworkOpsIpV7Test.test_bulk_create_delete_port + - tempest.api.network.test_networks.BulkNetworkOpsIpV6Test.test_bulk_create_delete_subnet |