diff --git a/backend/btrixcloud/pages.py b/backend/btrixcloud/pages.py index be5fdb2a..b8cd9c47 100644 --- a/backend/btrixcloud/pages.py +++ b/backend/btrixcloud/pages.py @@ -538,11 +538,9 @@ class PageOps: crawl_ids = await self.coll_ops.get_collection_crawl_ids( coll_id, public_or_unlisted_only ) - elif not crawl_ids: - # neither coll_id nor crawl_id, error - raise HTTPException( - status_code=400, detail="either crawl_ids or coll_id must be provided" - ) + + if not crawl_ids: + return [], 0 query: dict[str, object] = { "crawl_id": {"$in": crawl_ids}, diff --git a/backend/test/test_collections.py b/backend/test/test_collections.py index e3621b05..47a72ec2 100644 --- a/backend/test/test_collections.py +++ b/backend/test/test_collections.py @@ -155,6 +155,38 @@ def test_create_collection_empty_name( assert r.status_code == 422 +def test_create_empty_collection( + crawler_auth_headers, default_org_id, crawler_crawl_id, admin_crawl_id +): + r = requests.post( + f"{API_PREFIX}/orgs/{default_org_id}/collections", + headers=crawler_auth_headers, + json={ + "name": "Empty Collection", + }, + ) + assert r.status_code == 200 + coll_id = r.json()["id"] + + r = requests.get( + f"{API_PREFIX}/orgs/{default_org_id}/collections/{coll_id}/replay.json", + headers=crawler_auth_headers, + ) + assert r.status_code == 200 + data = r.json() + assert data["crawlCount"] == 0 + assert data["pageCount"] == 0 + assert len(data["resources"]) == 0 + + # Delete the empty collection + r = requests.delete( + f"{API_PREFIX}/orgs/{default_org_id}/collections/{coll_id}", + headers=crawler_auth_headers, + ) + assert r.status_code == 200 + assert r.json()["success"] + + def test_update_collection( crawler_auth_headers, default_org_id, crawler_crawl_id, admin_crawl_id ):