From 53888ba211cf5928c778d0c8719814d244f8e170 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Nov 03 2022 15:18:37 +0000 Subject: [PATCH 1/4] Make black style changes for the tests to pass --- diff --git a/pagure_distgit/forms.py b/pagure_distgit/forms.py index 50d62b5..a9eb789 100644 --- a/pagure_distgit/forms.py +++ b/pagure_distgit/forms.py @@ -17,7 +17,7 @@ import wtforms class AnityaForm(pagure.forms.PagureForm): - """ Form to configure taiga for a project. """ + """Form to configure taiga for a project.""" anitya_status = wtforms.SelectField( "Monitoring status of the package in anitya", @@ -35,7 +35,7 @@ class AnityaForm(pagure.forms.PagureForm): class OrphanReasonForm(pagure.forms.PagureForm): - """ Form for orphaning reason. """ + """Form for orphaning reason.""" orphan_reason = wtforms.SelectField( "Reason for orphaning package", @@ -58,7 +58,7 @@ class OrphanReasonForm(pagure.forms.PagureForm): class BZOverrideForm(pagure.forms.PagureForm): - """ Form to configure the Fedora/EPEL maintainer for a project. """ + """Form to configure the Fedora/EPEL maintainer for a project.""" fedora_assignee = wtforms.StringField( "Maintainer name", [wtforms.validators.optional(strip_whitespace=True)] diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index 3c9f37c..db18d92 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -136,11 +136,9 @@ def _is_active_in_pdc(name, namespace): "rpms": "rpm", "modules": "module", "container": "container", - "flatpaks": "flatpak" + "flatpaks": "flatpak", } - to_pdc_namespace = ( - flask.current_app.config.get("PDC_NAMESPACES") or to_pdc_namespace - ) + to_pdc_namespace = flask.current_app.config.get("PDC_NAMESPACES") or to_pdc_namespace try: pdc_namespace = to_pdc_namespace[namespace] @@ -148,8 +146,7 @@ def _is_active_in_pdc(name, namespace): raise pagure.exceptions.APIError( 500, error_code=APIERROR.ENOCODE, - error="Namespace: %s could not be converted to a PDC namespace" - % namespace, + error="Namespace: %s could not be converted to a PDC namespace" % namespace, ) branch = "master" @@ -184,9 +181,7 @@ def _is_active_in_pdc(name, namespace): error="The output of %s could not be converted to JSON" % req.url, ) - _log.info( - "%s/%s is active: %s", namespace, name, data["results"][0]["active"] - ) + _log.info("%s/%s is active: %s", namespace, name, data["results"][0]["active"]) return data["results"][0]["active"] is True @@ -267,9 +262,7 @@ def orphan_endpoint(namespace, repo): repo = _get_repo(repo, namespace=namespace) _check_token(repo, project_token=False) - user_obj = pagure.lib.query.get_user( - flask.g.session, flask.g.fas_user.username - ) + user_obj = pagure.lib.query.get_user(flask.g.session, flask.g.fas_user.username) if not user_obj: raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOUSER) @@ -278,8 +271,7 @@ def orphan_endpoint(namespace, repo): 401, error_code=APIERROR.EMODIFYPROJECTNOTALLOWED ) - if repo.user.user != flask.g.fas_user.username \ - and not pagure.utils.is_admin(): + if repo.user.user != flask.g.fas_user.username and not pagure.utils.is_admin(): raise pagure.exceptions.APIError( 401, error_code=APIERROR.EMODIFYPROJECTNOTALLOWED ) @@ -299,9 +291,7 @@ def orphan_endpoint(namespace, repo): reason_info=form.orphan_reason_info.data, ) flask.g.session.add(reason) - pagure.lib.query.set_project_owner( - flask.g.session, repo, orphan_user_obj - ) + pagure.lib.query.set_project_owner(flask.g.session, repo, orphan_user_obj) if user_obj in repo.users: pagure.lib.query.remove_user_of_project( flask.g.session, user_obj, repo, user_obj.user @@ -343,9 +333,7 @@ def take_orphan_endpoint(namespace, repo): repo = _get_repo(repo, namespace=namespace) _check_token(repo, project_token=False) - user_obj = pagure.lib.query.get_user( - flask.g.session, flask.g.fas_user.username - ) + user_obj = pagure.lib.query.get_user(flask.g.session, flask.g.fas_user.username) if not user_obj: raise pagure.exceptions.APIError(404, error_code=APIERROR.ENOUSER) @@ -398,7 +386,8 @@ def take_orphan_endpoint(namespace, repo): def query_oraculum_versions(package): """ Receives package versions from oraculum - Returns triplet: fedora-releases, updates-for-package, F%number-of-current-rawhide + Returns triplet: fedora-releases, updates-for-package, + F%number-of-current-rawhide """ oraculum_base_url = "https://packager-dashboard.fedoraproject.org/api/" @@ -412,8 +401,8 @@ def query_oraculum_versions(package): raise pagure.exceptions.APIError( 500, error_code=APIERROR.ENOCODE, - error="This pagure instance has no ORACULUM_URL configured, please " - "inform your pagure administrators", + error="This pagure instance has no ORACULUM_URL configured," + "please inform your pagure administrators", ) _log.debug("Based ORACULUM url: %s", oraculum_url) @@ -422,17 +411,17 @@ def query_oraculum_versions(package): if not req_releases.ok: raise pagure.exceptions.APIError( - 400, - error_code=APIERROR.EINVALIDREQ, - errors=["Could not call oraculum to query current Fedora Releases."], - ) + 400, + error_code=APIERROR.EINVALIDREQ, + errors=["Could not call oraculum to query current Fedora Releases."], + ) if not req_versions.ok: raise pagure.exceptions.APIError( - 400, - error_code=APIERROR.EINVALIDREQ, - errors=["Could not call oraculum to query current package versions."], - ) + 400, + error_code=APIERROR.EINVALIDREQ, + errors=["Could not call oraculum to query current package versions."], + ) versions_resp = req_versions.json() releases_resp = req_releases.json() @@ -466,10 +455,12 @@ def query_oraculum_versions(package): return releases, versions, rawhide + def query_bodhi_versions(repo): """ Receives package versions from bodhi - Returns triplet: fedora-releases, updates-for-package, F%number-of-current-rawhide + Returns triplet: fedora-releases, updates-for-package, + F%number-of-current-rawhide """ bodhi_base_url = "https://bodhi.fedoraproject.org/" @@ -559,6 +550,7 @@ def query_bodhi_versions(repo): return releases, updates, rawhide + @DISTGIT_NS.route("/bodhi_updates//", methods=["GET"]) @api_method def bodhi_updates_endpoint(namespace, repo): @@ -570,9 +562,7 @@ def bodhi_updates_endpoint(namespace, repo): errors=["Namespace not supported"], ) - _log.info( - "Received request for the bodhi updates of: %s/%s", namespace, repo - ) + _log.info("Received request for the bodhi updates of: %s/%s", namespace, repo) repo = _get_repo(repo, namespace=namespace) html = pagure.utils.is_true(flask.request.args.get("html", False)) @@ -604,7 +594,8 @@ def bodhi_updates_endpoint(namespace, repo): else: # This makes things a little slower but is needed for builds # that do not go through bodhi, for example, via releng-managed - # side tags (like for Fedora mass rebuilds), which bypass bodhi. + # side tags (like for Fedora mass rebuilds), + # which bypass bodhi. if release == rawhide: mdapi_release = "rawhide" else: @@ -625,9 +616,7 @@ def bodhi_updates_endpoint(namespace, repo): ) stable = ( "{0}".format( - build - ) + "terms={0}&type=build&match=exact'>{0}".format(build) ) testing = "" if updates.get(release, {}).get("testing"): @@ -637,9 +626,7 @@ def bodhi_updates_endpoint(namespace, repo): updates[release].get("testing") ) ) - row = row.format( - release=releases[release], stable=stable, testing=testing - ) + row = row.format(release=releases[release], stable=stable, testing=testing) html_output += row html_output += "" return html_output @@ -673,7 +660,7 @@ def bzoverride_patch_endpoint(repo, namespace): """Updates the default assignees of this package.""" def _validate_input(inputname): - """ Validate if the input is either an username or a group name. """ + """Validate if the input is either an username or a group name.""" valid = False if inputname.startswith("@"): group = pagure.lib.query.search_groups( @@ -683,9 +670,7 @@ def bzoverride_patch_endpoint(repo, namespace): valid = True else: - user_obj = pagure.lib.query.search_user( - flask.g.session, username=inputname - ) + user_obj = pagure.lib.query.search_user(flask.g.session, username=inputname) if user_obj: valid = True diff --git a/pagure_distgit_tests/test_bugzilla_overrides.py b/pagure_distgit_tests/test_bugzilla_overrides.py index c195d1f..6a57d62 100644 --- a/pagure_distgit_tests/test_bugzilla_overrides.py +++ b/pagure_distgit_tests/test_bugzilla_overrides.py @@ -1,20 +1,21 @@ from __future__ import print_function -import os import json +import os import pagure.lib.query -import tests from pagure_distgit import plugin +import tests + class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): - """ Tests the bugzilla override endpoints added in pagure-dist-git. """ + """Tests the bugzilla override endpoints added in pagure-dist-git.""" def setUp(self): - """ Set up the environnment, ran before every tests. """ + """Set up the environnment, ran before every tests.""" super(PagureFlaskApiProjectBZOverrideTests, self).setUp() self.session.flush() tests.create_projects(self.session) @@ -24,7 +25,7 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): self._app.register_blueprint(plugin.DISTGIT_NS) def test_default_values(self): - """Test the default values returned by the bz overrides endpoint. """ + """Test the default values returned by the bz overrides endpoint.""" expected_result = { "epel_assignee": "pingou", @@ -36,16 +37,16 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): self.assertDictEqual(data, expected_result) def test_token_missing_ACL(self): - """Test the bz endpoint with an API token missing the `modify_project` ACL.""" + """Test the bz endpoint with an API token missing the `modify_project` + ACL. + """ headers = {"Authorization": "token foo_token"} - output = self.app.post( - "/_dg/bzoverrides/somenamespace/test3", headers=headers - ) + output = self.app.post("/_dg/bzoverrides/somenamespace/test3", headers=headers) # invalid token self.assertEqual(output.status_code, 401) def test_invalid_token(self): - """Test the bz endpoint with an invalid API token. """ + """Test the bz endpoint with an invalid API token.""" headers = {"Authorization": "token BBBZZZOOO"} datainput = {} output = self.app.post( @@ -56,7 +57,7 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): self.assertEqual(output.status_code, 401) def test_change_both_assignee(self): - """Test the bz endpoint when changing both assignee at once. """ + """Test the bz endpoint when changing both assignee at once.""" headers = {"Authorization": "token aaabbbcccddd"} datainput = {"epel_assignee": "foo", "fedora_assignee": "foo"} output = self.app.post( @@ -193,9 +194,7 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertDictEqual( - data, {"epel_assignee": "pingou", "fedora_assignee": "foo"} - ) + self.assertDictEqual(data, {"epel_assignee": "pingou", "fedora_assignee": "foo"}) repo = pagure.lib.query.get_authorized_project( self.session, "test3", @@ -298,9 +297,7 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): with tests.user_set(self.app.application, user): # change one assignee datainput = {"epel_assignee": "foo"} - output = self.app.post( - "/_dg/bzoverrides/somenamespace/test3", data=datainput - ) + output = self.app.post("/_dg/bzoverrides/somenamespace/test3", data=datainput) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( @@ -308,16 +305,14 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): ) def test_change_fedora_assignee_logged_in(self): - """Test the bz endpoint when changing the Fedora assignee when logged in - the UI. + """Test the bz endpoint when changing the Fedora assignee when logged + in the UI. """ user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): # change one assignee datainput = {"fedora_assignee": "foo"} - output = self.app.post( - "/_dg/bzoverrides/somenamespace/test3", data=datainput - ) + output = self.app.post("/_dg/bzoverrides/somenamespace/test3", data=datainput) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( @@ -331,24 +326,19 @@ class PagureFlaskApiProjectBZOverrideTests(tests.Modeltests): user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): datainput = {"epel_assignee": "foo", "fedora_assignee": "foo"} - output = self.app.post( - "/_dg/bzoverrides/somenamespace/test3", data=datainput - ) + output = self.app.post("/_dg/bzoverrides/somenamespace/test3", data=datainput) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertDictEqual( - data, {"epel_assignee": "foo", "fedora_assignee": "foo"} - ) + self.assertDictEqual(data, {"epel_assignee": "foo", "fedora_assignee": "foo"}) def test_resetting_assignees_logged_in(self): - """Test the bz endpoint when resetting assignees when logged in the UI.""" + """Test the bz endpoint when resetting assignees when logged + in the UI.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): # Changing one of them before the reset datainput = {"epel_assignee": "foo"} - output = self.app.post( - "/_dg/bzoverrides/somenamespace/test3", data=datainput - ) + output = self.app.post("/_dg/bzoverrides/somenamespace/test3", data=datainput) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( diff --git a/pagure_distgit_tests/test_dist_git_auth.py b/pagure_distgit_tests/test_dist_git_auth.py index 1c1cd34..2182574 100644 --- a/pagure_distgit_tests/test_dist_git_auth.py +++ b/pagure_distgit_tests/test_dist_git_auth.py @@ -17,16 +17,14 @@ except ImportError: import tests -import dist_git_auth - class DistGitAuthTests(tests.Modeltests): - """ Test DistGitAuth ACLs with Fedora config. """ + """Test DistGitAuth ACLs with Fedora config.""" maxDiff = None def setUp(self): - """ Set up the environment in which to run the tests. """ + """Set up the environment in which to run the tests.""" super(DistGitAuthTests, self).setUp() pagure.config.config["ACL_DEBUG"] = True @@ -59,7 +57,7 @@ class DistGitAuthTests(tests.Modeltests): self.session.commit() def tearDown(self): - """ Tear down the environment in which the tests ran. """ + """Tear down the environment in which the tests ran.""" self.dga = None super(DistGitAuthTests, self).tearDown() @@ -99,9 +97,7 @@ class DistGitAuthTests(tests.Modeltests): if msg == expect_msg: found = True if not found: - raise AssertionError( - "Info message '%s' expected but not found" % expect_msg - ) + raise AssertionError("Info message '%s' expected but not found" % expect_msg) class DistGitAuthTestsGeneric(DistGitAuthTests): @@ -357,9 +353,7 @@ class DistGitAuthTestsGeneric(DistGitAuthTests): def test_unprotected_pr_required_repo_pr_only_no_pr(self): settings = {"pull_request_access_only": True} - project = self.create_namespaced_project( - "unprotected", "test", settings=settings - ) + project = self.create_namespaced_project("unprotected", "test", settings=settings) self.assertFalse( self.dga.check_acl( @@ -380,9 +374,7 @@ class DistGitAuthTestsGeneric(DistGitAuthTests): def test_unprotected_pr_required_repo_pr_only(self): settings = {"pull_request_access_only": True} - project = self.create_namespaced_project( - "unprotected", "test", settings=settings - ) + project = self.create_namespaced_project("unprotected", "test", settings=settings) self.assertTrue( self.dga.check_acl( self.session, @@ -554,9 +546,7 @@ class DistGitAuthTestsFedora(DistGitAuthTests): self.expect_info_msg("Unspecified ref refs/heads/f28 is blocked") @patch("dist_git_auth.requests") - def test_protected_unspecified_branch_normal_committer( - self, mock_requests - ): + def test_protected_unspecified_branch_normal_committer(self, mock_requests): project = self.create_namespaced_project("rpms", "test") res = Mock() res.ok = True @@ -581,9 +571,7 @@ class DistGitAuthTestsFedora(DistGitAuthTests): self.expect_info_msg("Unspecified branch push") @patch("dist_git_auth.requests") - def test_protected_unspecified_branch_normal_non_committer( - self, mock_requests - ): + def test_protected_unspecified_branch_normal_non_committer(self, mock_requests): project = self.create_namespaced_project("rpms", "test") res = Mock() res.ok = True @@ -665,9 +653,7 @@ class DistGitAuthTestsFedoraCommitterAccess(DistGitAuthTests): self.expect_info_msg("Fall-through deny") @patch("dist_git_auth.requests") - def test_protected_unspecified_branch_collaborator_valid_branch( - self, mock_requests - ): + def test_protected_unspecified_branch_collaborator_valid_branch(self, mock_requests): project = get_project(self.session, name="test", namespace="rpms") res = Mock() res.ok = True @@ -869,9 +855,7 @@ class DistGitAuthTestsFedoraBranchOverride(DistGitAuthTests): "RCM_BRANCHES": ["refs/heads/f[0-9]+"], "ACL_PROTECTED_NAMESPACES": ["rpms", "modules", "container"], "PDC_URL": "invalid://", - "PDC_BRANCH_OVERRIDES": { - "rpms": {"refs/heads/main": "refs/heads/rawhide"} - }, + "PDC_BRANCH_OVERRIDES": {"rpms": {"refs/heads/main": "refs/heads/rawhide"}}, } def setUp(self): @@ -957,9 +941,7 @@ class DistGitAuthTestsFedoraBranchOverride(DistGitAuthTests): @patch("dist_git_auth.requests") def test_pushing_to_containers_calls_pdc_correctly(self, mock_requests): - project = get_project( - self.session, name="cockpit", namespace="container" - ) + project = get_project(self.session, name="cockpit", namespace="container") res = Mock() res.ok = True res.json.return_value = {"results": []} diff --git a/pagure_distgit_tests/test_plugin.py b/pagure_distgit_tests/test_plugin.py index 39c5928..43e695c 100644 --- a/pagure_distgit_tests/test_plugin.py +++ b/pagure_distgit_tests/test_plugin.py @@ -1,31 +1,30 @@ import json import os -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch import pagure.lib.model import pagure.lib.query -import pygit2 from pagure_distgit import model from pagure_distgit import plugin +import pygit2 + import tests class PagureFlaskApiOrphanEndpointTests(tests.Modeltests): - """ Tests the orphan endpoint added in pagure-dist-git. """ + """Tests the orphan endpoint added in pagure-dist-git.""" def setUp(self): - """ Set up the environnment, ran before every tests. """ + """Set up the environnment, ran before every tests.""" super(PagureFlaskApiOrphanEndpointTests, self).setUp() self.session.flush() tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) - tests.create_user( - self.session, "orphan", "orphan", ["orphan@fedoraproject.org"] - ) + tests.create_user(self.session, "orphan", "orphan", ["orphan@fedoraproject.org"]) repo = pagure.lib.query.get_authorized_project( self.session, "test3", @@ -38,16 +37,16 @@ class PagureFlaskApiOrphanEndpointTests(tests.Modeltests): self._app.register_blueprint(plugin.DISTGIT_NS) def test_token_missing_ACL(self): - """Test the orphan endpoint with an API token missing the `modify_project` ACL.""" + """Test the orphan endpoint with an API token missing the + `modify_project` ACL. + """ headers = {"Authorization": "token foo_token"} - output = self.app.post( - "/_dg/orphan/somenamespace/test3", headers=headers - ) + output = self.app.post("/_dg/orphan/somenamespace/test3", headers=headers) # invalid token assert output.status_code == 401 def test_invalid_token(self): - """Test the orphan endpoint with an invalid API token. """ + """Test the orphan endpoint with an invalid API token.""" headers = {"Authorization": "token BBBZZZOOO"} datainput = {} output = self.app.post( @@ -187,19 +186,17 @@ class PagureFlaskApiOrphanEndpointTests(tests.Modeltests): class PagureFlaskApiOrphanGetEndpointTests(tests.Modeltests): - """ Tests the orphan get endpoint added in pagure-dist-git. """ + """Tests the orphan get endpoint added in pagure-dist-git.""" def setUp(self): - """ Set up the environnment, ran before every tests. """ + """Set up the environnment, ran before every tests.""" super(PagureFlaskApiOrphanGetEndpointTests, self).setUp() self.session.flush() tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) - tests.create_user( - self.session, "orphan", "orphan", ["orphan@fedoraproject.org"] - ) + tests.create_user(self.session, "orphan", "orphan", ["orphan@fedoraproject.org"]) repo = pagure.lib.query.get_authorized_project( self.session, "test3", @@ -274,19 +271,17 @@ class PagureFlaskApiOrphanGetEndpointTests(tests.Modeltests): class PagureFlaskApiTakeOrphanEndpointTests(tests.Modeltests): - """ Tests the take orphan endpoint added in pagure-dist-git. """ + """Tests the take orphan endpoint added in pagure-dist-git.""" def setUp(self): - """ Set up the environnment, ran before every tests. """ + """Set up the environnment, ran before every tests.""" super(PagureFlaskApiTakeOrphanEndpointTests, self).setUp() self.session.flush() tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) - tests.create_user( - self.session, "orphan", "orphan", ["orphan@fedoraproject.org"] - ) + tests.create_user(self.session, "orphan", "orphan", ["orphan@fedoraproject.org"]) pagure.lib.query.add_group( self.session, "packager", @@ -353,7 +348,7 @@ class PagureFlaskApiTakeOrphanEndpointTests(tests.Modeltests): assert output.status_code == 401 def test_invalid_token(self): - """Test the take orphan endpoint with an invalid API token. """ + """Test the take orphan endpoint with an invalid API token.""" headers = {"Authorization": "token BBBZZZOOO"} output = self.app.post( "/_dg/take_orphan/somenamespace/test3", diff --git a/pagure_distgit_tests/test_style.py b/pagure_distgit_tests/test_style.py index c2f4b9a..fdd777f 100644 --- a/pagure_distgit_tests/test_style.py +++ b/pagure_distgit_tests/test_style.py @@ -35,7 +35,8 @@ class TestStyle(unittest.TestCase): This test runs flake8 on the code, and will fail if it returns a non-zero exit code. """ - # We ignore E712, which disallows non-identity comparisons with True and False + # We ignore E712, which disallows non-identity comparisons with True + # and False # We ignore W503, which disallows line break before binary operator flake8_command = [ sys.executable, @@ -60,9 +61,7 @@ class TestStyle(unittest.TestCase): if old_flake: raise unittest.SkipTest("Flake8 version too old to be useful") - proc = subprocess.Popen( - flake8_command, stdout=subprocess.PIPE, cwd=REPO_PATH - ) + proc = subprocess.Popen(flake8_command, stdout=subprocess.PIPE, cwd=REPO_PATH) print(proc.communicate()) self.assertEqual(proc.returncode, 0) From ddf2ac0f1f1a134f5b4202d0dc3639de948cc5b9 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Nov 03 2022 15:19:35 +0000 Subject: [PATCH 2/4] Make flake8 changes for the tests to pass --- diff --git a/pagure_distgit_tests/test_dist_git_auth.py b/pagure_distgit_tests/test_dist_git_auth.py index 2182574..d94cdee 100644 --- a/pagure_distgit_tests/test_dist_git_auth.py +++ b/pagure_distgit_tests/test_dist_git_auth.py @@ -1,5 +1,7 @@ from __future__ import print_function +import dist_git_auth + from mock import Mock, patch import pagure.config diff --git a/pagure_distgit_tests/test_style.py b/pagure_distgit_tests/test_style.py index fdd777f..020a6f8 100644 --- a/pagure_distgit_tests/test_style.py +++ b/pagure_distgit_tests/test_style.py @@ -11,7 +11,7 @@ Tests for flake8 and black compliance of the code """ -from __future__ import unicode_literals, absolute_import +from __future__ import absolute_import, unicode_literals import os import subprocess @@ -42,7 +42,7 @@ class TestStyle(unittest.TestCase): sys.executable, "-m", "flake8", - "--ignore=E712,W503,E203", + "--ignore=E501,E712,W503,E203", REPO_PATH, ] From 348cf7368fb9bb6d758185574223562d674ef6e6 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Nov 03 2022 15:20:38 +0000 Subject: [PATCH 3/4] Allow lines of 90 chars and add regex symbol for flake8 to not complain --- diff --git a/pagure_distgit_tests/test_style.py b/pagure_distgit_tests/test_style.py index 020a6f8..dde8e24 100644 --- a/pagure_distgit_tests/test_style.py +++ b/pagure_distgit_tests/test_style.py @@ -81,10 +81,10 @@ class TestStyle(unittest.TestCase): "-m", "black", "-l", - "79", + "90", "--check", "--exclude", - '"/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|' + r'"/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|' '_build|buck-out|build|dist)/"', # noqa REPO_PATH, TESTS_PATH, From 8ad49f41b4417167512cb3e3351629bcaf194784 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Nov 03 2022 15:21:39 +0000 Subject: [PATCH 4/4] Fix tests failing for empty reason_info in orphaning packages --- diff --git a/pagure_distgit/plugin.py b/pagure_distgit/plugin.py index db18d92..5bb6e87 100644 --- a/pagure_distgit/plugin.py +++ b/pagure_distgit/plugin.py @@ -216,7 +216,11 @@ def orphan_get_endpoint(namespace, repo): output["orphan"] = True if repo.orphan_reason: output["reason"] = repo.orphan_reason.reason - output["reason_info"] = repo.orphan_reason.reason_info + output["reason_info"] = ( + "" + if repo.orphan_reason.reason_info is None + else repo.orphan_reason.reason_info + ) return flask.jsonify(output)