From dc733c31177b0ffdc4c30b9c4801b765909f1c50 Mon Sep 17 00:00:00 2001 From: helenyao Date: Thu, 1 Dec 2016 21:52:43 -0500 Subject: Rename TestCasesBase into TestcaseBase JIRA: FUNCTEST-628 1. rename the TestCasesBase into TestcaseBase 2. updated the module name to testcase_base.py Change-Id: Ic6b5d8209098c136613a2419c3790668fdbd493e Signed-off-by: helenyao --- functest/ci/exec_test.sh | 0 functest/ci/run_tests.py | 6 +- functest/core/TestCasesBase.py | 53 ------------- functest/core/testcase_base.py | 53 +++++++++++++ functest/opnfv_tests/features/domino.py | 8 +- functest/opnfv_tests/features/sdnvpn.py | 9 ++- functest/opnfv_tests/openstack/vping/vping_base.py | 22 +++--- functest/opnfv_tests/openstack/vping/vping_ssh.py | 8 +- functest/opnfv_tests/sdn/odl/odl.py | 8 +- functest/opnfv_tests/vnf/rnc/parser.py | 10 +-- functest/tests/unit/core/test_base.py | 87 ---------------------- functest/tests/unit/core/test_testcase_base.py | 87 ++++++++++++++++++++++ functest/tests/unit/odl/test_odl.py | 48 ++++++------ run_unit_tests.sh | 2 +- 14 files changed, 201 insertions(+), 200 deletions(-) mode change 100644 => 100755 functest/ci/exec_test.sh delete mode 100644 functest/core/TestCasesBase.py create mode 100644 functest/core/testcase_base.py delete mode 100644 functest/tests/unit/core/test_base.py create mode 100644 functest/tests/unit/core/test_testcase_base.py diff --git a/functest/ci/exec_test.sh b/functest/ci/exec_test.sh old mode 100644 new mode 100755 diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index 66d5881d..7de1577d 100644 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -18,7 +18,7 @@ import argparse import functest.ci.generate_report as generate_report import functest.ci.tier_builder as tb -import functest.core.TestCasesBase as TestCasesBase +import functest.core.testcase_base as testcase_base import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.functest_constants as ft_constants @@ -132,7 +132,7 @@ def run_test(test, tier_name): if GlobalVariables.REPORT_FLAG: flags += " -r" - result = TestCasesBase.TestCasesBase.EX_RUN_ERROR + result = testcase_base.TestcaseBase.EX_RUN_ERROR run_dict = get_run_dict_if_defined(test_name) if run_dict: try: @@ -140,7 +140,7 @@ def run_test(test, tier_name): cls = getattr(module, run_dict['class']) test_case = cls() result = test_case.run() - if (result == TestCasesBase.TestCasesBase.EX_OK and + if (result == testcase_base.TestCasesBase.EX_OK and GlobalVariables.REPORT_FLAG): result = test_case.push_to_db() except ImportError: diff --git a/functest/core/TestCasesBase.py b/functest/core/TestCasesBase.py deleted file mode 100644 index 777b09f0..00000000 --- a/functest/core/TestCasesBase.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2016 Orange and others. -# -# 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 - -import os - -import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as ft_utils - - -class TestCasesBase(object): - - EX_OK = os.EX_OK - EX_RUN_ERROR = os.EX_SOFTWARE - EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1 - - logger = ft_logger.Logger(__name__).getLogger() - - def __init__(self): - self.details = {} - self.project_name = "functest" - self.case_name = "" - self.criteria = "" - self.start_time = "" - self.stop_time = "" - - def run(self, **kwargs): - self.logger.error("Run must be implemented") - return TestCasesBase.EX_RUN_ERROR - - def push_to_db(self): - try: - assert self.project_name - assert self.case_name - assert self.criteria - assert self.start_time - assert self.stop_time - if ft_utils.push_results_to_db( - self.project_name, self.case_name, self.start_time, - self.stop_time, self.criteria, self.details): - self.logger.info("The results were successfully pushed to DB") - return TestCasesBase.EX_OK - else: - self.logger.error("The results cannot be pushed to DB") - return TestCasesBase.EX_PUSH_TO_DB_ERROR - except Exception: - self.logger.exception("The results cannot be pushed to DB") - return TestCasesBase.EX_PUSH_TO_DB_ERROR diff --git a/functest/core/testcase_base.py b/functest/core/testcase_base.py new file mode 100644 index 00000000..e869803d --- /dev/null +++ b/functest/core/testcase_base.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# Copyright (c) 2016 Orange and others. +# +# 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 + +import os + +import functest.utils.functest_logger as ft_logger +import functest.utils.functest_utils as ft_utils + + +class TestcaseBase(object): + + EX_OK = os.EX_OK + EX_RUN_ERROR = os.EX_SOFTWARE + EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1 + + logger = ft_logger.Logger(__name__).getLogger() + + def __init__(self): + self.details = {} + self.project_name = "functest" + self.case_name = "" + self.criteria = "" + self.start_time = "" + self.stop_time = "" + + def run(self, **kwargs): + self.logger.error("Run must be implemented") + return TestcaseBase.EX_RUN_ERROR + + def push_to_db(self): + try: + assert self.project_name + assert self.case_name + assert self.criteria + assert self.start_time + assert self.stop_time + if ft_utils.push_results_to_db( + self.project_name, self.case_name, self.start_time, + self.stop_time, self.criteria, self.details): + self.logger.info("The results were successfully pushed to DB") + return TestcaseBase.EX_OK + else: + self.logger.error("The results cannot be pushed to DB") + return TestcaseBase.EX_PUSH_TO_DB_ERROR + except Exception: + self.logger.exception("The results cannot be pushed to DB") + return TestcaseBase.EX_PUSH_TO_DB_ERROR diff --git a/functest/opnfv_tests/features/domino.py b/functest/opnfv_tests/features/domino.py index 4d882e15..45b93e7b 100755 --- a/functest/opnfv_tests/features/domino.py +++ b/functest/opnfv_tests/features/domino.py @@ -19,13 +19,13 @@ import os import sys import time -from functest.core import TestCasesBase +import functest.core.testcase_base as testcase_base import functest.utils.functest_constants as ft_constants import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils -class DominoCases(TestCasesBase.TestCasesBase): +class DominoCases(testcase_base.TestcaseBase): DOMINO_REPO = \ ft_constants.DOMINO_REPO_DIR RESULTS_DIR = \ @@ -72,9 +72,9 @@ if __name__ == '__main__': domino = DominoCases() try: result = domino.main(**args) - if result != TestCasesBase.TestCasesBase.EX_OK: + if result != testcase_base.TestcaseBase.EX_OK: sys.exit(result) if args['report']: sys.exit(domino.push_to_db()) except Exception: - sys.exit(TestCasesBase.TestCasesBase.EX_RUN_ERROR) + sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR) diff --git a/functest/opnfv_tests/features/sdnvpn.py b/functest/opnfv_tests/features/sdnvpn.py index 1c07fe14..451299eb 100644 --- a/functest/opnfv_tests/features/sdnvpn.py +++ b/functest/opnfv_tests/features/sdnvpn.py @@ -14,13 +14,13 @@ import os import sys import time -from functest.core import TestCasesBase +import functest.core.testcase_base as testcase_base import functest.utils.functest_constants as ft_constants import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils -class SdnVpnTests(TestCasesBase.TestCasesBase): +class SdnVpnTests(testcase_base.TestcaseBase): SDNVPN_REPO_TESTS = os.path.join( ft_constants.SDNVPN_REPO_DIR, "tests/functest") logger = ft_logger.Logger("sdnvpn").getLogger() @@ -58,6 +58,7 @@ class SdnVpnTests(TestCasesBase.TestCasesBase): kwargs = {} return self.main(**kwargs) + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("-r", "--report", @@ -67,9 +68,9 @@ if __name__ == '__main__': sdnvpn = SdnVpnTests() try: result = sdnvpn.main(**args) - if result != TestCasesBase.TestCasesBase.EX_OK: + if result != testcase_base.TestcaseBase.EX_OK: sys.exit(result) if args['report']: sys.exit(sdnvpn.push_to_db()) except Exception: - sys.exit(TestCasesBase.TestCasesBase.EX_RUN_ERROR) + sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR) diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 00177a22..213b79fc 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -15,10 +15,10 @@ from datetime import datetime import functest.utils.functest_utils as ft_utils import functest.utils.functest_constants as ft_constants import functest.utils.openstack_utils as os_utils -from functest.core import TestCasesBase +import functest.core.testcase_base as testcase_base -class VPingBase(TestCasesBase.TestCasesBase): +class VPingBase(testcase_base.TestcaseBase): def __init__(self): def get_conf(parameter): return ft_utils.get_functest_config(parameter) @@ -55,23 +55,23 @@ class VPingBase(TestCasesBase.TestCasesBase): def run(self, **kwargs): if not self.check_repo_exist(): - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR image_id = self.create_image() if not image_id: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR flavor = self.get_flavor() if not flavor: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR network_id = self.create_network_full() if not network_id: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR sg_id = self.create_security_group() if not sg_id: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR self.delete_exist_vms() @@ -87,7 +87,7 @@ class VPingBase(TestCasesBase.TestCasesBase): None, sg_id) if not vm1: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR test_ip = self.get_test_ip(vm1) vm2 = self.boot_vm(self.vm2_name, @@ -97,17 +97,17 @@ class VPingBase(TestCasesBase.TestCasesBase): test_ip, sg_id) if not vm2: - return TestCasesBase.TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR EXIT_CODE = self.do_vping(vm2, test_ip) - if EXIT_CODE == TestCasesBase.TestCasesBase.EX_RUN_ERROR: + if EXIT_CODE == testcase_base.TestcaseBase.EX_RUN_ERROR: return EXIT_CODE self.stop_time = time.time() self.parse_result(EXIT_CODE, self.start_time, self.stop_time) - return TestCasesBase.TestCasesBase.EX_OK + return testcase_base.TestcaseBase.EX_OK def boot_vm_preparation(self, config, vmname, test_ip): pass diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py index 48913857..8ae590ed 100644 --- a/functest/opnfv_tests/openstack/vping/vping_ssh.py +++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py @@ -19,7 +19,7 @@ from scp import SCPClient import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as os_utils import vping_base -from functest.core.TestCasesBase import TestCasesBase +import functest.core.testcase_base as testcase_base class VPingSSH(vping_base.VPingBase): @@ -32,12 +32,12 @@ class VPingSSH(vping_base.VPingBase): def do_vping(self, vm, test_ip): floatip = self.add_float_ip(vm) if not floatip: - return TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR ssh = self.establish_ssh(vm, floatip) if not ssh: - return TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR if not self.transfer_ping_script(ssh, floatip): - return TestCasesBase.EX_RUN_ERROR + return testcase_base.TestcaseBase.EX_RUN_ERROR return self.do_vping_ssh(ssh, test_ip) def add_float_ip(self, vm): diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index c3fcb241..95440746 100755 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -20,7 +20,7 @@ from robot.errors import RobotError import robot.run from robot.utils.robottime import timestamp_to_secs -from functest.core import TestCasesBase +import functest.core.testcase_base as testcase_base import functest.utils.functest_logger as ft_logger import functest.utils.openstack_utils as op_utils import functest.utils.functest_constants as ft_constants @@ -47,7 +47,7 @@ class ODLResultVisitor(ResultVisitor): return self._data -class ODLTests(TestCasesBase.TestCasesBase): +class ODLTests(testcase_base.TestcaseBase): repos = ft_constants.REPOS_DIR odl_test_repo = os.path.join(repos, "odl_test") @@ -233,9 +233,9 @@ if __name__ == '__main__': odl = ODLTests() try: result = odl.main(**args) - if result != TestCasesBase.TestCasesBase.EX_OK: + if result != testcase_base.TestcaseBase.EX_OK: sys.exit(result) if args['pushtodb']: sys.exit(odl.push_to_db()) except Exception: - sys.exit(TestCasesBase.TestCasesBase.EX_RUN_ERROR) + sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR) diff --git a/functest/opnfv_tests/vnf/rnc/parser.py b/functest/opnfv_tests/vnf/rnc/parser.py index f653220a..a50d4f1e 100644 --- a/functest/opnfv_tests/vnf/rnc/parser.py +++ b/functest/opnfv_tests/vnf/rnc/parser.py @@ -20,13 +20,13 @@ import time import argparse -import functest.core.TestCasesBase as base +import functest.core.testcase_base as testcase_base import functest.utils.functest_constants as ft_constants import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils -class Parser(base.TestCasesBase): +class Parser(testcase_base.TestcaseBase): def __init__(self): super(Parser, self).__init__() @@ -34,7 +34,7 @@ class Parser(base.TestCasesBase): self.case_name = "parser-basics" self.logger = ft_logger.Logger("parser").getLogger() self.log_file = os.path.join( - ft_constants.FUNCTEST_RESULTS_DIR, "parser.log") + ft_constants.FUNCTEST_RESULTS_DIR, "parser.log") def run(self, **kwargs): cmd = 'cd %s/tests && ./functest_run.sh' % ft_constants.PARSER_REPO_DIR @@ -71,9 +71,9 @@ if __name__ == '__main__': parser = Parser() try: result = parser.run(**args) - if result != base.TestCasesBase.EX_OK: + if result != testcase_base.TestcaseBase.EX_OK: sys.exit(result) if args['report']: sys.exit(parser.push_to_db()) except Exception: - sys.exit(base.TestCasesBase.EX_RUN_ERROR) + sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR) diff --git a/functest/tests/unit/core/test_base.py b/functest/tests/unit/core/test_base.py deleted file mode 100644 index 154cc78a..00000000 --- a/functest/tests/unit/core/test_base.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2016 Orange and others. -# -# 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 - -import logging -import mock -import unittest - -from functest.core import TestCasesBase - - -class TestCasesBaseTesting(unittest.TestCase): - - logging.disable(logging.CRITICAL) - - def setUp(self): - self.test = TestCasesBase.TestCasesBase() - self.test.project = "functest" - self.test.case_name = "base" - self.test.start_time = "1" - self.test.stop_time = "2" - self.test.criteria = "100" - self.test.details = {"Hello": "World"} - - def test_run_unimplemented(self): - self.assertEqual(self.test.run(), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) - - @mock.patch('functest.utils.functest_utils.push_results_to_db', - return_value=False) - def _test_missing_attribute(self, mock_function): - self.assertEqual(self.test.push_to_db(), - TestCasesBase.TestCasesBase.EX_PUSH_TO_DB_ERROR) - mock_function.assert_not_called() - - def test_missing_case_name(self): - self.test.case_name = None - self._test_missing_attribute() - - def test_missing_criteria(self): - self.test.criteria = None - self._test_missing_attribute() - - def test_missing_start_time(self): - self.test.start_time = None - self._test_missing_attribute() - - def test_missing_stop_time(self): - self.test.stop_time = None - self._test_missing_attribute() - - @mock.patch('functest.utils.functest_utils.push_results_to_db', - return_value=True) - def test_missing_details(self, mock_function): - self.test.details = None - self.assertEqual(self.test.push_to_db(), - TestCasesBase.TestCasesBase.EX_OK) - mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, - self.test.stop_time, self.test.criteria, self.test.details) - - @mock.patch('functest.utils.functest_utils.push_results_to_db', - return_value=False) - def test_push_to_db_failed(self, mock_function): - self.assertEqual(self.test.push_to_db(), - TestCasesBase.TestCasesBase.EX_PUSH_TO_DB_ERROR) - mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, - self.test.stop_time, self.test.criteria, self.test.details) - - @mock.patch('functest.utils.functest_utils.push_results_to_db', - return_value=True) - def test_push_to_db(self, mock_function): - self.assertEqual(self.test.push_to_db(), - TestCasesBase.TestCasesBase.EX_OK) - mock_function.assert_called_once_with( - self.test.project, self.test.case_name, self.test.start_time, - self.test.stop_time, self.test.criteria, self.test.details) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/functest/tests/unit/core/test_testcase_base.py b/functest/tests/unit/core/test_testcase_base.py new file mode 100644 index 00000000..fe7b0d05 --- /dev/null +++ b/functest/tests/unit/core/test_testcase_base.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +# Copyright (c) 2016 Orange and others. +# +# 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 + +import logging +import mock +import unittest + +import functest.core.testcase_base as testcase_base + + +class TestcaseBaseTesting(unittest.TestCase): + + logging.disable(logging.CRITICAL) + + def setUp(self): + self.test = testcase_base.TestcaseBase() + self.test.project = "functest" + self.test.case_name = "base" + self.test.start_time = "1" + self.test.stop_time = "2" + self.test.criteria = "100" + self.test.details = {"Hello": "World"} + + def test_run_unimplemented(self): + self.assertEqual(self.test.run(), + testcase_base.TestcaseBase.EX_RUN_ERROR) + + @mock.patch('functest.utils.functest_utils.push_results_to_db', + return_value=False) + def _test_missing_attribute(self, mock_function): + self.assertEqual(self.test.push_to_db(), + testcase_base.TestcaseBase.EX_PUSH_TO_DB_ERROR) + mock_function.assert_not_called() + + def test_missing_case_name(self): + self.test.case_name = None + self._test_missing_attribute() + + def test_missing_criteria(self): + self.test.criteria = None + self._test_missing_attribute() + + def test_missing_start_time(self): + self.test.start_time = None + self._test_missing_attribute() + + def test_missing_stop_time(self): + self.test.stop_time = None + self._test_missing_attribute() + + @mock.patch('functest.utils.functest_utils.push_results_to_db', + return_value=True) + def test_missing_details(self, mock_function): + self.test.details = None + self.assertEqual(self.test.push_to_db(), + testcase_base.TestcaseBase.EX_OK) + mock_function.assert_called_once_with( + self.test.project, self.test.case_name, self.test.start_time, + self.test.stop_time, self.test.criteria, self.test.details) + + @mock.patch('functest.utils.functest_utils.push_results_to_db', + return_value=False) + def test_push_to_db_failed(self, mock_function): + self.assertEqual(self.test.push_to_db(), + testcase_base.TestcaseBase.EX_PUSH_TO_DB_ERROR) + mock_function.assert_called_once_with( + self.test.project, self.test.case_name, self.test.start_time, + self.test.stop_time, self.test.criteria, self.test.details) + + @mock.patch('functest.utils.functest_utils.push_results_to_db', + return_value=True) + def test_push_to_db(self, mock_function): + self.assertEqual(self.test.push_to_db(), + testcase_base.TestcaseBase.EX_OK) + mock_function.assert_called_once_with( + self.test.project, self.test.case_name, self.test.start_time, + self.test.stop_time, self.test.criteria, self.test.details) + + +if __name__ == "__main__": + unittest.main(verbosity=2) diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py index 46707e82..ef18016b 100644 --- a/functest/tests/unit/odl/test_odl.py +++ b/functest/tests/unit/odl/test_odl.py @@ -15,7 +15,7 @@ import unittest from robot.errors import RobotError -from functest.core import TestCasesBase +import functest.core.testcase_base as testcase_base from functest.opnfv_tests.sdn.odl import odl from functest.utils import functest_constants as ft_constants @@ -113,7 +113,7 @@ class ODLTesting(unittest.TestCase): def _test_main_missing_keyword(self, key): kwargs = self._get_main_kwargs(key) self.assertEqual(self.test.main(**kwargs), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_main_missing_odlusername(self): self._test_main_missing_keyword('odlusername') @@ -148,7 +148,7 @@ class ODLTesting(unittest.TestCase): def test_main_set_robotframework_vars_failed(self): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=False): - self._test_main(TestCasesBase.TestCasesBase.EX_RUN_ERROR) + self._test_main(testcase_base.TestcaseBase.EX_RUN_ERROR) self.test.set_robotframework_vars.assert_called_once_with( self._odl_username, self._odl_password) @@ -157,14 +157,14 @@ class ODLTesting(unittest.TestCase): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ self.assertRaises(Exception): - self._test_main(TestCasesBase.TestCasesBase.EX_RUN_ERROR, + self._test_main(testcase_base.TestcaseBase.EX_RUN_ERROR, mock_method) @mock.patch('os.makedirs', side_effect=OSError) def test_main_makedirs_oserror(self, mock_method): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True): - self._test_main(TestCasesBase.TestCasesBase.EX_RUN_ERROR, + self._test_main(testcase_base.TestcaseBase.EX_RUN_ERROR, mock_method) @mock.patch('robot.run', side_effect=RobotError) @@ -173,7 +173,7 @@ class ODLTesting(unittest.TestCase): with mock.patch.object(self.test, 'set_robotframework_vars', return_value=True), \ self.assertRaises(RobotError): - self._test_main(TestCasesBase.TestCasesBase.EX_RUN_ERROR, *args) + self._test_main(testcase_base.TestcaseBase.EX_RUN_ERROR, *args) @mock.patch('robot.run') @mock.patch('os.makedirs') @@ -182,7 +182,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results', side_effect=RobotError): - self._test_main(TestCasesBase.TestCasesBase.EX_RUN_ERROR, *args) + self._test_main(testcase_base.TestcaseBase.EX_RUN_ERROR, *args) @mock.patch('os.remove', side_effect=Exception) @mock.patch('robot.run') @@ -192,7 +192,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results'), \ self.assertRaises(Exception): - self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args) + self._test_main(testcase_base.TestcaseBase.EX_OK, *args) @mock.patch('os.remove') @mock.patch('robot.run') @@ -202,7 +202,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results', return_value="PASS"): - self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args) + self._test_main(testcase_base.TestcaseBase.EX_OK, *args) @mock.patch('os.remove') @mock.patch('robot.run') @@ -212,7 +212,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results', return_value="PASS"): - self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args) + self._test_main(testcase_base.TestcaseBase.EX_OK, *args) @mock.patch('os.remove') @mock.patch('robot.run', return_value=1) @@ -222,7 +222,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results', return_value="PASS"): - self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args) + self._test_main(testcase_base.TestcaseBase.EX_OK, *args) @mock.patch('os.remove', side_effect=OSError) @mock.patch('robot.run') @@ -232,7 +232,7 @@ class ODLTesting(unittest.TestCase): return_value=True), \ mock.patch.object(self.test, 'parse_results', return_value="PASS"): - self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args) + self._test_main(testcase_base.TestcaseBase.EX_OK, *args) def _test_run_missing_env_var(self, var): if var == 'OS_USERNAME': @@ -243,9 +243,9 @@ class ODLTesting(unittest.TestCase): ft_constants.OS_TENANT_NAME = None self.assertEqual(self.test.run(), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) + testcase_base.TestcaseBase.EX_RUN_ERROR) - def _test_run(self, status=TestCasesBase.TestCasesBase.EX_OK, + def _test_run(self, status=testcase_base.TestcaseBase.EX_OK, exception=None, odlip="127.0.0.3", odlwebport="8080"): with mock.patch('functest.utils.openstack_utils.get_keystone_client', return_value=self._get_fake_keystone_client()): @@ -274,7 +274,7 @@ class ODLTesting(unittest.TestCase): def test_run_main_false(self): ft_constants.CI_INSTALLER_TYPE = None ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip - self._test_run(TestCasesBase.TestCasesBase.EX_RUN_ERROR, + self._test_run(testcase_base.TestcaseBase.EX_RUN_ERROR, odlip=self._sdn_controller_ip, odlwebport=self._odl_webport) @@ -282,7 +282,7 @@ class ODLTesting(unittest.TestCase): ft_constants.CI_INSTALLER_TYPE = None ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip with self.assertRaises(Exception): - self._test_run(status=TestCasesBase.TestCasesBase.EX_RUN_ERROR, + self._test_run(status=testcase_base.TestcaseBase.EX_RUN_ERROR, exception=Exception(), odlip=self._sdn_controller_ip, odlwebport=self._odl_webport) @@ -293,18 +293,18 @@ class ODLTesting(unittest.TestCase): ft_constants.CI_INSTALLER_TYPE = None ft_constants.SDN_CONTROLLER_IP = None self.assertEqual(self.test.run(), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_without_installer_type(self): ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip ft_constants.CI_INSTALLER_TYPE = None - self._test_run(TestCasesBase.TestCasesBase.EX_OK, + self._test_run(testcase_base.TestcaseBase.EX_OK, odlip=self._sdn_controller_ip, odlwebport=self._odl_webport) def test_run_fuel(self): ft_constants.CI_INSTALLER_TYPE = "fuel" - self._test_run(TestCasesBase.TestCasesBase.EX_OK, + self._test_run(testcase_base.TestcaseBase.EX_OK, odlip=self._neutron_ip, odlwebport='8282') def test_run_apex_missing_sdn_controller_ip(self): @@ -313,12 +313,12 @@ class ODLTesting(unittest.TestCase): ft_constants.CI_INSTALLER_TYPE = "apex" ft_constants.SDN_CONTROLLER_IP = None self.assertEqual(self.test.run(), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_apex(self): ft_constants.SDN_CONTROLLER_IP = self._sdn_controller_ip ft_constants.CI_INSTALLER_TYPE = "apex" - self._test_run(TestCasesBase.TestCasesBase.EX_OK, + self._test_run(testcase_base.TestcaseBase.EX_OK, odlip=self._sdn_controller_ip, odlwebport='8181') def test_run_joid_missing_sdn_controller(self): @@ -327,18 +327,18 @@ class ODLTesting(unittest.TestCase): ft_constants.CI_INSTALLER_TYPE = "joid" ft_constants.SDN_CONTROLLER = None self.assertEqual(self.test.run(), - TestCasesBase.TestCasesBase.EX_RUN_ERROR) + testcase_base.TestcaseBase.EX_RUN_ERROR) def test_run_joid(self): ft_constants.SDN_CONTROLLER = self._sdn_controller_ip ft_constants.CI_INSTALLER_TYPE = "joid" - self._test_run(TestCasesBase.TestCasesBase.EX_OK, + self._test_run(testcase_base.TestcaseBase.EX_OK, odlip=self._sdn_controller_ip, odlwebport=self._odl_webport) def test_run_compass(self, *args): ft_constants.CI_INSTALLER_TYPE = "compass" - self._test_run(TestCasesBase.TestCasesBase.EX_OK, + self._test_run(testcase_base.TestcaseBase.EX_OK, odlip=self._neutron_ip, odlwebport='8181') diff --git a/run_unit_tests.sh b/run_unit_tests.sh index a8ce54c4..9f7bb504 100755 --- a/run_unit_tests.sh +++ b/run_unit_tests.sh @@ -55,7 +55,7 @@ export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml nosetests --with-xunit \ --with-coverage \ --cover-erase \ - --cover-package=functest.core.TestCasesBase \ + --cover-package=functest.core.testcase_base \ --cover-package=functest.opnfv_tests.sdn.odl.odl \ --cover-xml \ --cover-html \ -- cgit 1.2.3-korg