-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix content__in filter #5818
Merged
Merged
Fix content__in filter #5818
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed Publication & RepositoryVersion's `content__in` filter to properly accept an array of strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -934,7 +934,7 @@ def test_content_in_repository_version_view( | |
pulpcore_bindings, | ||
file_bindings, | ||
file_repository_factory, | ||
file_random_content_unit, | ||
file_content_unit_with_name_factory, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes!!! |
||
monitor_task, | ||
): | ||
"""Sync two repositories and check view filter.""" | ||
|
@@ -950,17 +950,17 @@ def test_content_in_repository_version_view( | |
|
||
repo = file_repository_factory() | ||
repo2 = file_repository_factory() | ||
all_content = [file_content_unit_with_name_factory(str(uuid4())) for i in range(3)] | ||
content = choice(all_content) | ||
|
||
# Add content to first repo and assert repo-ver list w/ content is correct | ||
body = {"add_content_units": [file_random_content_unit.pulp_href]} | ||
body = {"add_content_units": [content.pulp_href]} | ||
task = file_bindings.RepositoriesFileApi.modify(repo.pulp_href, body).task | ||
monitor_task(task) | ||
repo = file_bindings.RepositoriesFileApi.read(repo.pulp_href) | ||
assert repo.latest_version_href[-2] == "1" | ||
|
||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list( | ||
content=file_random_content_unit.pulp_href | ||
) | ||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list(content=content.pulp_href) | ||
assert repo_vers.count == 1 | ||
assert repo_vers.results[0].pulp_href == repo.latest_version_href | ||
|
||
|
@@ -970,11 +970,47 @@ def test_content_in_repository_version_view( | |
repo2 = file_bindings.RepositoriesFileApi.read(repo2.pulp_href) | ||
assert repo2.latest_version_href[-2] == "1" | ||
|
||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list( | ||
content=file_random_content_unit.pulp_href | ||
) | ||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list(content=content.pulp_href) | ||
assert repo_vers.count == 2 | ||
assert {r.pulp_href for r in repo_vers.results} == { | ||
repo.latest_version_href, | ||
repo2.latest_version_href, | ||
} | ||
|
||
# Test that content__in w/ one unit gives identical results to content filter | ||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list(content__in=[content.pulp_href]) | ||
assert repo_vers.count == 2 | ||
assert {r.pulp_href for r in repo_vers.results} == { | ||
repo.latest_version_href, | ||
repo2.latest_version_href, | ||
} | ||
|
||
# Add all content to first repo and assert content__in w/ more content returns 1 repo-ver | ||
all_content_href = [c.pulp_href for c in all_content] | ||
body = {"add_content_units": all_content_href} | ||
task = file_bindings.RepositoriesFileApi.modify(repo.pulp_href, body).task | ||
monitor_task(task) | ||
repo = file_bindings.RepositoriesFileApi.read(repo.pulp_href) | ||
assert repo.latest_version_href[-2] == "2" | ||
|
||
contents = list(set(all_content_href) - {content.pulp_href}) | ||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list(content__in=contents) | ||
assert repo_vers.count == 1 | ||
assert repo_vers.results[0].pulp_href == repo.latest_version_href | ||
|
||
# Add back the first content and assert that all 3 repo-vers are returned | ||
contents.append(content.pulp_href) | ||
repo_vers = pulpcore_bindings.RepositoryVersionsApi.list(content__in=contents) | ||
assert repo_vers.count == 3 | ||
assert {r.pulp_href for r in repo_vers.results} == { | ||
f"{repo.versions_href}1/", | ||
repo.latest_version_href, | ||
repo2.latest_version_href, | ||
} | ||
|
||
# Test content__in validates the hrefs passed in | ||
contents.append(non_existant_content_href) | ||
with pytest.raises(pulpcore_bindings.ApiException) as e: | ||
pulpcore_bindings.RepositoryVersionsApi.list(content__in=contents) | ||
|
||
assert e.value.status == 400 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
BaseInFilter
what fixes the openapi3 schema in this case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add a schema test for this.