From 161d40585a25291da548dfdade2838974e86ad58 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Tue, 15 Aug 2017 06:49:51 +0000 Subject: Obtain build_tag by CONST instead of get function JIRA: FUNCTEST-763 Change-Id: I86b0b515a3d51df20a35c2aeb461a95d0c5797fd Signed-off-by: Linda Wang --- functest/tests/unit/utils/test_functest_utils.py | 42 ++++++------------------ 1 file changed, 10 insertions(+), 32 deletions(-) (limited to 'functest/tests') diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py index 98c7d6e9..b4cc5b73 100644 --- a/functest/tests/unit/utils/test_functest_utils.py +++ b/functest/tests/unit/utils/test_functest_utils.py @@ -133,24 +133,20 @@ class FunctestUtilsTesting(unittest.TestCase): self.assertEqual(functest_utils.get_scenario(), self.scenario) - @mock.patch('functest.utils.functest_utils.get_build_tag') - def test_get_version_daily_job(self, mock_get_build_tag): - mock_get_build_tag.return_value = self.build_tag + def test_get_version_daily_job(self): + CONST.__setattr__('BUILD_TAG', self.build_tag) self.assertEqual(functest_utils.get_version(), self.version) - @mock.patch('functest.utils.functest_utils.get_build_tag') - def test_get_version_weekly_job(self, mock_get_build_tag): - mock_get_build_tag.return_value = self.build_tag_week + def test_get_version_weekly_job(self): + CONST.__setattr__('BUILD_TAG', self.build_tag_week) self.assertEqual(functest_utils.get_version(), self.version) - @mock.patch('functest.utils.functest_utils.get_build_tag') - def test_get_version_with_dummy_build_tag(self, mock_get_build_tag): - mock_get_build_tag.return_value = 'whatever' + def test_get_version_with_dummy_build_tag(self): + CONST.__setattr__('BUILD_TAG', 'whatever') self.assertEqual(functest_utils.get_version(), 'unknown') - @mock.patch('functest.utils.functest_utils.get_build_tag') - def test_get_version_unknown(self, mock_get_build_tag): - mock_get_build_tag.return_value = "unknown_build_tag" + def test_get_version_unknown(self): + CONST.__setattr__('BUILD_TAG', 'unknown_build_tag') self.assertEqual(functest_utils.get_version(), "unknown") @mock.patch('functest.utils.functest_utils.logger.info') @@ -172,34 +168,16 @@ class FunctestUtilsTesting(unittest.TestCase): self.assertEqual(functest_utils.get_pod_name(), self.node_name) - @mock.patch('functest.utils.functest_utils.logger.info') - def test_get_build_tag_failed(self, mock_logger_info): - with mock.patch.dict(os.environ, - {}, - clear=True): - self.assertEqual(functest_utils.get_build_tag(), - "none") - mock_logger_info.assert_called_once_with("Impossible to retrieve" - " the build tag") - - def test_get_build_tag_default(self): - with mock.patch.dict(os.environ, - {'BUILD_TAG': self.build_tag}, - clear=True): - self.assertEqual(functest_utils.get_build_tag(), - self.build_tag) - @mock.patch('functest.utils.functest_utils.logger.info') def test_logger_test_results(self, mock_logger_info): CONST.__setattr__('results_test_db_url', self.db_url) + CONST.__setattr__('BUILD_TAG', self.build_tag) with mock.patch('functest.utils.functest_utils.get_pod_name', return_value=self.node_name), \ mock.patch('functest.utils.functest_utils.get_scenario', return_value=self.scenario), \ mock.patch('functest.utils.functest_utils.get_version', - return_value=self.version), \ - mock.patch('functest.utils.functest_utils.get_build_tag', - return_value=self.build_tag): + return_value=self.version): functest_utils.logger_test_results(self.project, self.case_name, self.status, self.details) mock_logger_info.assert_called_once_with( -- cgit 1.2.3-korg