Skip to content
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

Allow querying on multiple gating statuses simultaneously #5658

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bodhi-server/bodhi/server/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ class Status(colander.SequenceSchema):
validator=colander.OneOf(list(UpdateStatus.values())))


class GatingStatus(colander.SequenceSchema):
"""A SequenceSchema to validate a list of TestGatingStatus objects."""

status = colander.SchemaNode(colander.String(),
validator=colander.OneOf(list(TestGatingStatus.values())))


class Tests(colander.SequenceSchema):
"""A SequenceSchema to validate a list of Test objects."""

Expand Down Expand Up @@ -653,11 +660,11 @@ class ListUpdateSchema(PaginatedSchema, SearchableSchema, Cosmetics):
preparer=[util.splitter],
)

gating = colander.SchemaNode(
colander.String(),
gating = GatingStatus(
colander.Sequence(accept_scalar=True),
location="querystring",
missing=None,
validator=colander.OneOf(list(TestGatingStatus.values())),
preparer=[util.splitter],
)


Expand Down
2 changes: 1 addition & 1 deletion bodhi-server/bodhi/server/services/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def query_updates(request):

gating_status = data.get('gating')
if gating_status is not None:
query = query.filter(Update.test_gating_status == gating_status)
query = query.filter(or_(*[Update.test_gating_status == s for s in gating_status]))

user = data.get('user')
if user is not None:
Expand Down
20 changes: 20 additions & 0 deletions bodhi-server/tests/services/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2956,6 +2956,26 @@ def test_list_updates_by_gating_status(self):
assert up['alias'] == f'FEDORA-{YEAR}-a3bbe1a8f2'
assert up['karma'] == 1

def test_list_updates_by_gating_status_multiple(self):
# set the bodhi update's gating status to passed, add two
# updates with different gating statuses, query for those
# two statuses and expect to find those updates but not the
# bodhi update
bodhi = self.db.query(Build).filter_by(nvr='bodhi-2.0-1.fc17').one().update
bodhi.test_gating_status = TestGatingStatus.passed
firefox = self.create_update(['firefox-61.0.2-3.fc17'])
firefox.test_gating_status = TestGatingStatus.failed
python_nose = self.create_update(['python-nose-1.3.7-11.fc17'])
python_nose.test_gating_status = TestGatingStatus.waiting
self.db.commit()

res = self.app.get('/updates/', {"gating": ["failed", "waiting"]})
body = res.json_body
assert len(body['updates']) == 2
expected = ['firefox-61.0.2-3.fc17', 'python-nose-1.3.7-11.fc17']
actual = sorted(update['title'] for update in body['updates'])
assert expected == actual

def test_list_updates_by_from_side_tag(self):
up = self.db.query(Build).filter_by(nvr='bodhi-2.0-1.fc17').one().update
up.from_tag = 'f33-side-tag'
Expand Down
1 change: 1 addition & 0 deletions news/PR5658.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When searching updates, you can now specify multiple gating statuses by passing the 'gating' query arg more than once