From 3f29dd2f11e3bb847fce5ac56060758d6076e8e7 Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Mon, 4 Dec 2017 08:33:59 +0000 Subject: Improve the pylint score of functest-core It also modifies the file list to ensure the rating of ci modules. Change-Id: Ia1e414be5364cb3da3d54882db428024ed6bd99f Signed-off-by: Linda Wang --- functest/tests/unit/ci/test_check_deployment.py | 7 +++++-- functest/tests/unit/ci/test_run_tests.py | 24 +++++++++++------------- functest/tests/unit/ci/test_tier_builder.py | 2 ++ functest/tests/unit/ci/test_tier_handler.py | 8 +++++--- 4 files changed, 23 insertions(+), 18 deletions(-) (limited to 'functest/tests/unit') diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py index 66d1b7af..fa2f2130 100644 --- a/functest/tests/unit/ci/test_check_deployment.py +++ b/functest/tests/unit/ci/test_check_deployment.py @@ -172,11 +172,14 @@ class CheckDeploymentTesting(unittest.TestCase): @mock.patch('functest.ci.check_deployment.LOGGER.info') @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.' - 'get_ext_net_name', return_value='ext-net') + 'get_ext_net_name') def test_check_extnet(self, mock_getext, mock_loginfo): + test_network = 'ext-net' + mock_getext.return_value = test_network self.deployment.check_ext_net() self.assertTrue(mock_getext.called) - mock_loginfo.assert_called_once_with("External network found: ext-net") + mock_loginfo.assert_called_once_with( + "External network found: %s", test_network) @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.' 'get_ext_net_name', return_value='') diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py index bc95f8f3..93cbfccd 100644 --- a/functest/tests/unit/ci/test_run_tests.py +++ b/functest/tests/unit/ci/test_run_tests.py @@ -58,14 +58,14 @@ class RunTestsTesting(unittest.TestCase): self.run_tests_parser = run_tests.RunTestsParser() - @mock.patch('functest.ci.run_tests.logger.error') + @mock.patch('functest.ci.run_tests.LOGGER.error') def test_source_rc_file_missing_file(self, mock_logger_error): with mock.patch('functest.ci.run_tests.os.path.isfile', return_value=False), \ self.assertRaises(Exception): self.runner.source_rc_file() - @mock.patch('functest.ci.run_tests.logger.debug') + @mock.patch('functest.ci.run_tests.LOGGER.debug') @mock.patch('functest.ci.run_tests.os.path.isfile', return_value=True) def test_source_rc_file_default(self, *args): @@ -81,7 +81,7 @@ class RunTestsTesting(unittest.TestCase): self.assertEqual(self.runner.get_run_dict('test_name'), mock_obj) - @mock.patch('functest.ci.run_tests.logger.error') + @mock.patch('functest.ci.run_tests.LOGGER.error') def test_get_run_dict_if_defined_missing_config_option(self, mock_logger_error): with mock.patch('functest.ci.run_tests.' @@ -90,9 +90,8 @@ class RunTestsTesting(unittest.TestCase): testname = 'test_name' self.assertEqual(self.runner.get_run_dict(testname), None) - mock_logger_error.assert_called_once_with("Cannot get {}'s config " - "options" - .format(testname)) + mock_logger_error.assert_called_once_with( + "Cannot get %s's config options", testname) with mock.patch('functest.ci.run_tests.' 'ft_utils.get_dict_by_test', @@ -101,7 +100,7 @@ class RunTestsTesting(unittest.TestCase): self.assertEqual(self.runner.get_run_dict(testname), None) - @mock.patch('functest.ci.run_tests.logger.exception') + @mock.patch('functest.ci.run_tests.LOGGER.exception') def test_get_run_dict_if_defined_exception(self, mock_logger_except): with mock.patch('functest.ci.run_tests.' @@ -110,9 +109,8 @@ class RunTestsTesting(unittest.TestCase): testname = 'test_name' self.assertEqual(self.runner.get_run_dict(testname), None) - mock_logger_except.assert_called_once_with("Cannot get {}'s config" - " options" - .format(testname)) + mock_logger_except.assert_called_once_with( + "Cannot get %s's config options", testname) def test_run_tests_import_test_class_exception(self): mock_test = mock.Mock() @@ -153,14 +151,14 @@ class RunTestsTesting(unittest.TestCase): run_tests.Result.EX_OK) mock_methods[0].assert_called_with(mock.ANY) - @mock.patch('functest.ci.run_tests.logger.info') + @mock.patch('functest.ci.run_tests.LOGGER.info') def test_run_tier_missing_test(self, mock_logger_info): self.tier.get_tests.return_value = None self.assertEqual(self.runner.run_tier(self.tier), run_tests.Result.EX_ERROR) self.assertTrue(mock_logger_info.called) - @mock.patch('functest.ci.run_tests.logger.info') + @mock.patch('functest.ci.run_tests.LOGGER.info') @mock.patch('functest.ci.run_tests.Runner.run_tier') @mock.patch('functest.ci.run_tests.Runner.summary') def test_run_all_default(self, *mock_methods): @@ -169,7 +167,7 @@ class RunTestsTesting(unittest.TestCase): mock_methods[1].assert_not_called() self.assertTrue(mock_methods[2].called) - @mock.patch('functest.ci.run_tests.logger.info') + @mock.patch('functest.ci.run_tests.LOGGER.info') @mock.patch('functest.ci.run_tests.Runner.summary') def test_run_all_missing_tier(self, *mock_methods): CONST.__setattr__('CI_LOOP', 'loop_re_not_available') diff --git a/functest/tests/unit/ci/test_tier_builder.py b/functest/tests/unit/ci/test_tier_builder.py index 1dec9aed..d832ca3f 100644 --- a/functest/tests/unit/ci/test_tier_builder.py +++ b/functest/tests/unit/ci/test_tier_builder.py @@ -5,6 +5,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 +# pylint: disable=missing-docstring + import logging import unittest diff --git a/functest/tests/unit/ci/test_tier_handler.py b/functest/tests/unit/ci/test_tier_handler.py index 1909ac22..871220db 100644 --- a/functest/tests/unit/ci/test_tier_handler.py +++ b/functest/tests/unit/ci/test_tier_handler.py @@ -5,6 +5,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 +# pylint: disable=missing-docstring + import logging import unittest @@ -89,11 +91,11 @@ class TierHandlerTesting(unittest.TestCase): self.assertEqual(self.tier.get_ci_loop(), 'test_ci_loop') - def test_testcase_is_none_present_item(self): + def test_testcase_is_none_in_item(self): self.assertEqual(tier_handler.TestCase.is_none("item"), False) - def test_testcase_is_none_missing_item(self): + def test_testcase_is_none_no_item(self): self.assertEqual(tier_handler.TestCase.is_none(None), True) @@ -102,7 +104,7 @@ class TierHandlerTesting(unittest.TestCase): 'test_scenario'), True) - def test_testcase_is_compatible_missing_installer_scenario(self): + def test_testcase_is_compatible_2(self): self.assertEqual(self.testcase.is_compatible('missing_installer', 'test_scenario'), False) -- cgit 1.2.3-korg