From 8f92a2cbfb6729f111d9e131afdbe0850ddd2e0c Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Tue, 28 Mar 2017 14:46:30 +0200 Subject: Rename test_testcase_base to test_testcase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It follows "Rename testcase_base to testcase" [1] [1] https://gerrit.opnfv.org/gerrit/#/c/31879/ Change-Id: I54bb62a37bdab842f433790688128a459b0ac78c Signed-off-by: Cédric Ollivier --- functest/tests/unit/core/test_testcase.py | 103 +++++++++++++++++++++++++ functest/tests/unit/core/test_testcase_base.py | 103 ------------------------- 2 files changed, 103 insertions(+), 103 deletions(-) create mode 100644 functest/tests/unit/core/test_testcase.py delete mode 100644 functest/tests/unit/core/test_testcase_base.py (limited to 'functest/tests') diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py new file mode 100644 index 00000000..9ee1609f --- /dev/null +++ b/functest/tests/unit/core/test_testcase.py @@ -0,0 +1,103 @@ +#!/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 unittest + +import mock + +from functest.core import testcase + + +class TestCaseTesting(unittest.TestCase): + + logging.disable(logging.CRITICAL) + + def setUp(self): + self.test = testcase.TestCase() + self.test.project = "functest" + self.test.case_name = "base" + self.test.start_time = "1" + self.test.stop_time = "2" + self.test.criteria = "PASS" + self.test.details = {"Hello": "World"} + + def test_run_unimplemented(self): + self.assertEqual(self.test.run(), + testcase.TestCase.EX_RUN_ERROR) + + @mock.patch('functest.utils.functest_utils.push_results_to_db', + return_value=False) + def _test_missing_attribute(self, mock_function=None): + self.assertEqual(self.test.push_to_db(), + testcase.TestCase.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=None): + self.test.details = None + self.assertEqual(self.test.push_to_db(), + testcase.TestCase.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=None): + self.assertEqual(self.test.push_to_db(), + testcase.TestCase.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=None): + self.assertEqual(self.test.push_to_db(), + testcase.TestCase.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) + + def test_check_criteria_missing(self): + self.test.criteria = None + self.assertEqual(self.test.check_criteria(), + testcase.TestCase.EX_TESTCASE_FAILED) + + def test_check_criteria_failed(self): + self.test.criteria = 'FAILED' + self.assertEqual(self.test.check_criteria(), + testcase.TestCase.EX_TESTCASE_FAILED) + + def test_check_criteria_pass(self): + self.test.criteria = 'PASS' + self.assertEqual(self.test.check_criteria(), + testcase.TestCase.EX_OK) + + +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 deleted file mode 100644 index 9ee1609f..00000000 --- a/functest/tests/unit/core/test_testcase_base.py +++ /dev/null @@ -1,103 +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 unittest - -import mock - -from functest.core import testcase - - -class TestCaseTesting(unittest.TestCase): - - logging.disable(logging.CRITICAL) - - def setUp(self): - self.test = testcase.TestCase() - self.test.project = "functest" - self.test.case_name = "base" - self.test.start_time = "1" - self.test.stop_time = "2" - self.test.criteria = "PASS" - self.test.details = {"Hello": "World"} - - def test_run_unimplemented(self): - self.assertEqual(self.test.run(), - testcase.TestCase.EX_RUN_ERROR) - - @mock.patch('functest.utils.functest_utils.push_results_to_db', - return_value=False) - def _test_missing_attribute(self, mock_function=None): - self.assertEqual(self.test.push_to_db(), - testcase.TestCase.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=None): - self.test.details = None - self.assertEqual(self.test.push_to_db(), - testcase.TestCase.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=None): - self.assertEqual(self.test.push_to_db(), - testcase.TestCase.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=None): - self.assertEqual(self.test.push_to_db(), - testcase.TestCase.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) - - def test_check_criteria_missing(self): - self.test.criteria = None - self.assertEqual(self.test.check_criteria(), - testcase.TestCase.EX_TESTCASE_FAILED) - - def test_check_criteria_failed(self): - self.test.criteria = 'FAILED' - self.assertEqual(self.test.check_criteria(), - testcase.TestCase.EX_TESTCASE_FAILED) - - def test_check_criteria_pass(self): - self.test.criteria = 'PASS' - self.assertEqual(self.test.check_criteria(), - testcase.TestCase.EX_OK) - - -if __name__ == "__main__": - unittest.main(verbosity=2) -- cgit 1.2.3-korg