diff --git a/pubtools/_pulp/tasks/push/items/base.py b/pubtools/_pulp/tasks/push/items/base.py index dcb1a4e8..b19ff3c4 100644 --- a/pubtools/_pulp/tasks/push/items/base.py +++ b/pubtools/_pulp/tasks/push/items/base.py @@ -111,7 +111,7 @@ def upload_repo(self): Subclasses MAY override this to return a variable default destination. Subclasses must set MULTI_UPLOAD_CONTEXT to True for this to be used. """ - return "" # pragma: no cover + return "" # pragma: no cover @classmethod def for_item(cls, pushsource_item, **kwargs): diff --git a/pubtools/_pulp/tasks/push/items/erratum.py b/pubtools/_pulp/tasks/push/items/erratum.py index 1002639c..d5022747 100644 --- a/pubtools/_pulp/tasks/push/items/erratum.py +++ b/pubtools/_pulp/tasks/push/items/erratum.py @@ -47,13 +47,17 @@ def upload_repo(self): # is formatted like RHXA-YYYY name_match = self.ADVISORY_PATTERN.match(self.pushsource_item.name) if not name_match: - LOG.error("Bad Advisory name: '%s' does not contain a reasonable year value.", - self.pushsource_item.name) + LOG.error( + "Bad Advisory name: '%s' does not contain a reasonable year value.", + self.pushsource_item.name, + ) raise ErratumPushItemException year = int(name_match.group(1)) if not any([r[0] <= year <= r[1] for r in self.CONTENT_SPLIT_RANGES]): - LOG.warning("%s was not in a valid date range for repo content splitting, using the default.", - self.pushsource_item.name ) + LOG.warning( + "%s was not in a valid date range for repo content splitting, using the default.", + self.pushsource_item.name, + ) year = "0000" return "all-erratum-content-%s" % year diff --git a/pubtools/_pulp/tasks/push/phase/upload.py b/pubtools/_pulp/tasks/push/phase/upload.py index 3b3cf445..8e375370 100644 --- a/pubtools/_pulp/tasks/push/phase/upload.py +++ b/pubtools/_pulp/tasks/push/phase/upload.py @@ -64,12 +64,15 @@ def run(self): if item_type not in upload_context: upload_context[item_type] = {} if item.upload_repo not in upload_context[item_type]: - upload_context[item_type][item.upload_repo] = \ + upload_context[item_type][item.upload_repo] = ( item.upload_context(self.pulp_client) + ) ctx = upload_context[item_type][item.upload_repo] else: if item_type not in upload_context: - upload_context[item_type] = item.upload_context(self.pulp_client) + upload_context[item_type] = item.upload_context( + self.pulp_client + ) ctx = upload_context[item_type] uploading += 1 self.put_future_output(item.ensure_uploaded(ctx)) diff --git a/tests/fake/test_fake_persistence.py b/tests/fake/test_fake_persistence.py index e5ed28b2..58df64b2 100644 --- a/tests/fake/test_fake_persistence.py +++ b/tests/fake/test_fake_persistence.py @@ -24,10 +24,15 @@ def test_state_persisted(tmpdir, data_path): # It should already have a few repos since there is some default # state. repo_ids = sorted([repo.id for repo in client.search_repository()]) - assert repo_ids == ["all-erratum-content-2019", "all-erratum-content-2020", - "all-iso-content", "all-rpm-content", - "all-rpm-content-54", "all-rpm-content-e8", - "redhat-maintenance"] + assert repo_ids == [ + "all-erratum-content-2019", + "all-erratum-content-2020", + "all-iso-content", + "all-rpm-content", + "all-rpm-content-54", + "all-rpm-content-e8", + "redhat-maintenance", + ] # Now add a bit more state. # We use modules here because that's one of the more complex types diff --git a/tests/push/test_pulperratumpushitem.py b/tests/push/test_pulperratumpushitem.py index 22b61346..340f6a91 100644 --- a/tests/push/test_pulperratumpushitem.py +++ b/tests/push/test_pulperratumpushitem.py @@ -1,9 +1,14 @@ from pubtools.pulplib import ErratumUnit from pushsource import ErratumPushItem -from pubtools._pulp.tasks.push.items import PulpErratumPushItem, State, ErratumPushItemException +from pubtools._pulp.tasks.push.items import ( + PulpErratumPushItem, + State, + ErratumPushItemException, +) import pytest + def test_erratum_publishes_all_repos(): item = PulpErratumPushItem( # We're being asked to push an advisory to a few repos... @@ -31,12 +36,11 @@ def test_erratum_publishes_all_repos(): # all-rpm-content is an exception given that those repos don't get published. assert item.publish_pulp_repos == ["existing1", "existing2", "new1", "new2"] + def test_erratum_upload_repo_normal(): # Test upload_repo maps name to expected repo - item = PulpErratumPushItem( - pushsource_item=ErratumPushItem(name="RHSA-2019:1234") - ) + item = PulpErratumPushItem(pushsource_item=ErratumPushItem(name="RHSA-2019:1234")) assert item.upload_repo == "all-erratum-content-2019" @@ -45,14 +49,11 @@ def test_erratum_upload_repo_default(): # Test upload_repo maps name to default repo when advisory year is outside # the expected range - item = PulpErratumPushItem( - pushsource_item=ErratumPushItem(name="RHSA-1999:1234") - ) + item = PulpErratumPushItem(pushsource_item=ErratumPushItem(name="RHSA-1999:1234")) assert item.upload_repo == "all-erratum-content-0000" - def test_erratum_upload_repo_bad_format(): # Test upload_repo throws an exception when no year value can be parsed # from the advisory name @@ -61,4 +62,4 @@ def test_erratum_upload_repo_bad_format(): item = PulpErratumPushItem( pushsource_item=ErratumPushItem(name="RHSA-fail:1234") ) - item.upload_repo \ No newline at end of file + item.upload_repo diff --git a/tests/push/test_push_prepush.py b/tests/push/test_push_prepush.py index 8c1f4ce9..5b3b55d5 100644 --- a/tests/push/test_push_prepush.py +++ b/tests/push/test_push_prepush.py @@ -58,8 +58,10 @@ def test_pre_push( assert units # RPMs are separated into different arc repos by checksum - expected_repo_mapping = {"test-srpm01": ["all-rpm-content-54"], - "walrus": ["all-rpm-content-e8"]} + expected_repo_mapping = { + "test-srpm01": ["all-rpm-content-54"], + "walrus": ["all-rpm-content-e8"], + } for unit in units: # The only type of content is RPMs, because that's all we support for