Skip to content

Commit

Permalink
fixup! Issue #139 remove deprecated collection_whitelist config
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Apr 3, 2024
1 parent 66d1d72 commit 9bd56e4
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,52 +275,6 @@ def test_collections_links(self, api100, requests_mock, backend1, backend2):
"links": [],
}

@pytest.mark.parametrize(
["collection_whitelist", "expected"],
[
(None, {"S1", "S2", "S3", "S4"}),
([], {"S1", "S2", "S3", "S4"}),
(["S2"], {"S2"}),
(["S4"], {"S4"}),
(["S2", "S3"], {"S2", "S3"}),
(["S2", "S999"], {"S2"}),
(["S999"], set()),
([re.compile(r"S[23]")], {"S2", "S3"}),
([re.compile(r"S")], set()),
([re.compile(r"S.*")], {"S1", "S2", "S3", "S4"}),
([re.compile(r"S2.*")], {"S2"}),
([re.compile(r".*2")], {"S2"}),
],
)
def test_collections_whitelist_legacy(
self, api100, requests_mock, backend1, backend2, collection_whitelist, expected
):
requests_mock.get(backend1 + "/collections", json={"collections": [{"id": "S1"}, {"id": "S2"}, {"id": "S3"}]})
for cid in ["S1", "S2", "S3"]:
requests_mock.get(backend1 + f"/collections/{cid}", json={"id": cid, "title": f"b1 {cid}"})
requests_mock.get(backend2 + "/collections", json={"collections": [{"id": "S3"}, {"id": "S4"}]})
for cid in ["S3", "S4"]:
requests_mock.get(backend2 + f"/collections/{cid}", json={"id": cid, "title": f"b2 {cid}"})

with config_overrides(collection_whitelist=collection_whitelist):
res = api100.get("/collections").assert_status_code(200).json
assert set(c["id"] for c in res["collections"]) == expected

res = api100.get("/collections/S2")
if "S2" in expected:
assert res.assert_status_code(200).json == DictSubSet({"id": "S2", "title": "b1 S2"})
else:
res.assert_error(404, "CollectionNotFound")

res = api100.get("/collections/S3")
if "S3" in expected:
assert res.assert_status_code(200).json == DictSubSet({"id": "S3", "title": "b1 S3"})
else:
res.assert_error(404, "CollectionNotFound")

res = api100.get("/collections/S999")
res.assert_error(404, "CollectionNotFound")

@pytest.mark.parametrize(
["collection_allow_list", "expected"],
[
Expand Down

0 comments on commit 9bd56e4

Please sign in to comment.