Skip to content

Commit

Permalink
Merge pull request #230 from jajreidy/fix-fake-match-all
Browse files Browse the repository at this point in the history
Fixes matching to all when searching content in the fake client
  • Loading branch information
rajulkumar authored Jan 28, 2025
2 parents 90e730e + 7db4caa commit 5db5ffd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pubtools/pulplib/_impl/fake/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def match_field_exists(_matcher, field, obj):
@visit(InMatcher)
def match_in(matcher, field, obj):
value = get_field(field, obj)
if field == "content_type_id" and not matcher._values:
return True
for elem in matcher._values:
if elem == value:
return True
Expand Down
9 changes: 9 additions & 0 deletions tests/fake/test_fake_search_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,12 @@ def test_search_content_files(populated_repo):
files=["/some/file", "/another/file", "/yet/another/file", "/script"],
)
]


def test_search_content_all_type_ids(populated_repo):
"""search_content with field content_type_ids and []"""

crit = Criteria.with_field_in("content_type_id", [])
units = list(populated_repo.search_content(crit))

assert len(units) == 7

0 comments on commit 5db5ffd

Please sign in to comment.