Skip to content

Commit

Permalink
Do not crash if collection has unexpected review status (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem authored Feb 1, 2022
1 parent 1dbe146 commit 335e0df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions checks/remotesettings/collections_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ async def has_inconsistencies(server_url, auth, resource):
# Collection status is reset on any modification, so if status is ``to-review``,
# then records in the source should be exactly the same as the records in the preview
if status == "to-review":
if "preview" not in resource:
return "{bucket}/{collection} should not have 'to-review' status".format(
**resource["source"]
)

source_records = await client.get_records(**source)
preview_records = await client.get_records(**resource["preview"])
diff = compare_collections(source_records, preview_records)
Expand Down
14 changes: 14 additions & 0 deletions tests/checks/remotesettings/test_collections_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ async def test_has_inconsistencies_unsupported_status(mock_responses):
assert "Unexpected status" in result


async def test_unexpected_review_status(mock_responses):
server_url = "http://fake.local/v1"
collection_url = server_url + COLLECTION_URL.format(
"security-workspace", "blocklist"
)
mock_responses.get(
collection_url, payload={"data": {"id": "blocklist", "status": "to-review"}}
)

result = await has_inconsistencies(server_url, FAKE_AUTH, RESOURCES[1])

assert result == "security-workspace/blocklist should not have 'to-review' status"


async def test_has_inconsistencies_to_review_preview_differs(mock_responses):
server_url = "http://fake.local/v1"
resource = {
Expand Down

0 comments on commit 335e0df

Please sign in to comment.