From 6dbd7492f2091087d6adfd4b97cdad7f6c419040 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:20:12 +0100 Subject: [PATCH 1/6] Adding w605 to ignore as that escape sequence is for latex --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index da1298e8..840c692c 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,7 @@ skip_install = true commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} -u - flake8 mlx tests setup.py + flake8 --ignore=W605 mlx tests setup.py [testenv:py36-check] deps = From e89c1b5f5e3bbaa68ab9d2cd3033905765d5486f Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:24:11 +0100 Subject: [PATCH 2/6] Fixing flake warnings --- mlx/coverity_services.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlx/coverity_services.py b/mlx/coverity_services.py index 8128969f..aa1f5014 100644 --- a/mlx/coverity_services.py +++ b/mlx/coverity_services.py @@ -224,7 +224,7 @@ def get_snapshot_id(snapshots, idx=1): if abs(required) > 0 and abs(required) <= num_snapshots: # base zero - return snapshots[required-1].id + return snapshots[required - 1].id return 0 def get_snapshot_detail(self, snapshot_id): @@ -396,7 +396,7 @@ def get_defects(self, project, stream, checker=None, impact=None, kind=None, cla name_value_pair = name_value_pair.strip() valid, name, values = parse_two_part_term(name_value_pair, ':') if valid: - logging.info("attr (%d) [%s] = any of ...", i+1, name) + logging.info("attr (%d) [%s] = any of ...", i + 1, name) attribute_definition_id = self.client.factory.create('attributeDefinitionIdDataObj') attribute_definition_id.name = name From 77ebb7bcb7f7c3c1a8ac76d90bd2f1513a3a80b9 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:29:19 +0100 Subject: [PATCH 3/6] Adding to 36 tox the warning skip --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 840c692c..23e68d33 100644 --- a/tox.ini +++ b/tox.ini @@ -69,7 +69,7 @@ skip_install = true commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} -u - flake8 mlx tests setup.py + flake8 --ignore=W605 mlx tests setup.py [testenv:py36-coveralls] From 753ca06df1705ede14e6f08638f3083a93b485b5 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:29:31 +0100 Subject: [PATCH 4/6] Fixing flake unused warning --- tests/test_coverity.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_coverity.py b/tests/test_coverity.py index f70ce11b..2624b85a 100644 --- a/tests/test_coverity.py +++ b/tests/test_coverity.py @@ -2,7 +2,7 @@ try: from unittest.mock import MagicMock, patch # from unittest.mock import call -except ImportError as err: +except ImportError: from mock import MagicMock, patch # from mock import call import mlx.coverity as cov @@ -95,3 +95,22 @@ def test_defect_service_defects(self, suds_client_mock, suds_security_mock, suds suds_username_mock.assert_called_once_with('user', 'password') coverity_service.get_defects('projectname', 'somestream') + + @patch('mlx.coverity_services.UsernameToken') + @patch('mlx.coverity_services.Security') + @patch('mlx.coverity_services.Client') + def test_configuration_service_login_no_username_error(self, suds_client_mock, suds_security_mock, suds_username_mock): + ''' Test login function of CoverityConfigurationService when error occurs''' + suds_client_mock.return_value = MagicMock(spec=Client) + suds_client_mock.return_value.service = MagicMock(spec=covservices.Service) + suds_client_mock.return_value.service.getVersion = MagicMock() + suds_security_mock.return_value = MagicMock(spec=Security) + suds_security_mock.return_value.tokens = [] + + # Login to Coverity and obtain stream information + coverity_conf_service = cov.CoverityConfigurationService('http', 'scan.coverity.com', '8080') + suds_client_mock.assert_called_once_with('http://scan.coverity.com:8080/ws/v9/configurationservice?wsdl') + + suds_client_mock.side_effect = Exception((401, 'Unauthorized')) + coverity_conf_service.login('', '') + From b1b8e2c1ae2580208d50464c098372b84feb071b Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:33:08 +0100 Subject: [PATCH 5/6] We want blank line on the end of file - helps git --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 23e68d33..1a6f3617 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,7 @@ skip_install = true commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} -u - flake8 --ignore=W605 mlx tests setup.py + flake8 --ignore=W605,W391 mlx tests setup.py [testenv:py36-check] deps = @@ -69,7 +69,7 @@ skip_install = true commands = python setup.py check --strict --metadata --restructuredtext check-manifest {toxinidir} -u - flake8 --ignore=W605 mlx tests setup.py + flake8 --ignore=W605,W391 mlx tests setup.py [testenv:py36-coveralls] From 21379d82845348d12e11a114a84b2c8332361bfe Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Wed, 19 Dec 2018 09:33:27 +0100 Subject: [PATCH 6/6] Fixing too long line in tests --- tests/test_coverity.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_coverity.py b/tests/test_coverity.py index 2624b85a..11318b48 100644 --- a/tests/test_coverity.py +++ b/tests/test_coverity.py @@ -99,7 +99,8 @@ def test_defect_service_defects(self, suds_client_mock, suds_security_mock, suds @patch('mlx.coverity_services.UsernameToken') @patch('mlx.coverity_services.Security') @patch('mlx.coverity_services.Client') - def test_configuration_service_login_no_username_error(self, suds_client_mock, suds_security_mock, suds_username_mock): + def test_configuration_service_login_no_username_error(self, suds_client_mock, suds_security_mock, + suds_username_mock): ''' Test login function of CoverityConfigurationService when error occurs''' suds_client_mock.return_value = MagicMock(spec=Client) suds_client_mock.return_value.service = MagicMock(spec=covservices.Service)