Skip to content

Commit

Permalink
Taught prune() to call remove_content() with a Content queryset.
Browse files Browse the repository at this point in the history
Fixed test broken by a typo-fix in core error-msg.

fixes #3778
  • Loading branch information
ggainey committed Nov 7, 2024
1 parent 5d81100 commit 8725d02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES/3778.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix traceback from prune() call discovered after `pulp/pulpcore#5934` addressed.
4 changes: 3 additions & 1 deletion pulp_rpm/app/tasks/prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pulpcore.plugin.models import ProgressReport
from pulpcore.plugin.constants import TASK_STATES
from pulpcore.plugin.models import (
Content,
GroupProgressReport,
RepositoryContent,
TaskGroup,
Expand Down Expand Up @@ -91,8 +92,9 @@ def prune_repo_packages(repo_pk, keep_days, dry_run):
):
log.debug(f'{p["name"]}-{p["epoch"]}:{p["version"]}-{p["release"]}.{p["arch"]}')
else:
content_q = Content.objects.filter(pk__in=target_ids_q)
with repo.new_version(base_version=None) as new_version:
new_version.remove_content(target_ids_q)
new_version.remove_content(content_q)
data["done"] = to_be_removed

pb = ProgressReport(**data)
Expand Down
8 changes: 2 additions & 6 deletions pulp_rpm/tests/functional/api/test_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,13 @@ def test_object_creation(
rpm_repository_api.create(repo_body, pulp_domain=domain.name)
assert e.value.status == 400
# What key should this error be under? non-field-errors seems wrong
assert json.loads(e.value.body) == {
"non_field_errors": [f"Objects must all be apart of the {domain_name} domain."]
}
assert "non_field_errors" in e.value.body

with pytest.raises(ApiException) as e:
sync_body = {"remote": default_remote.pulp_href}
rpm_repository_api.sync(repo.pulp_href, sync_body)
assert e.value.status == 400
assert json.loads(e.value.body) == {
"non_field_errors": [f"Objects must all be apart of the {domain_name} domain."]
}
assert "non_field_errors" in e.value.body


@pytest.mark.parallel
Expand Down

0 comments on commit 8725d02

Please sign in to comment.