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/tests/unit/core/test_base.py | 87 -------------------------- functest/tests/unit/core/test_testcase_base.py | 87 ++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 functest/tests/unit/core/test_base.py create mode 100644 functest/tests/unit/core/test_testcase_base.py (limited to 'functest/tests/unit/core') 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) -- cgit 1.2.3-korg