Skip to content

Commit 3efa5d2

Browse files
committed
Fixes matching to all when searching content in the fake client
1 parent 2c7ce6f commit 3efa5d2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/pubtools/pulplib/_impl/fake/match.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def match_field_exists(_matcher, field, obj):
123123
@visit(InMatcher)
124124
def match_in(matcher, field, obj):
125125
value = get_field(field, obj)
126+
if not matcher._values:
127+
return True
126128
for elem in matcher._values:
127129
if elem == value:
128130
return True

tests/fake/test_fake_search_content.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ def test_search_content_by_type(populated_repo):
137137
]
138138

139139

140+
def test_search_content_by_type_all(populated_repo):
141+
"""search_content for particular type returns matching content"""
142+
143+
crit = Criteria.with_field_in("content_type_id", [])
144+
units = list(populated_repo.search_content(crit))
145+
# assert we got all the units
146+
assert len(units) == 7
147+
148+
140149
def test_search_content_with_fields(populated_repo):
141150
"""search_content can limit fields"""
142151

0 commit comments

Comments
 (0)