diff --git a/backend/btrixcloud/crawls.py b/backend/btrixcloud/crawls.py index fd3e137a..369350de 100644 --- a/backend/btrixcloud/crawls.py +++ b/backend/btrixcloud/crawls.py @@ -875,12 +875,10 @@ class CrawlOps: async def remove_collection_from_all_crawls(self, collection_id: uuid.UUID): """Remove collection id from all crawls it's currently in.""" - result = await self.crawls.update_many( + await self.crawls.update_many( {"collections": collection_id}, {"$pull": {"collections": collection_id}}, ) - if result.modified_count < 1: - raise HTTPException(status_code=404, detail="crawls_not_found") # ============================================================================ diff --git a/backend/test/test_collections.py b/backend/test/test_collections.py index 2fc890b3..c60210ae 100644 --- a/backend/test/test_collections.py +++ b/backend/test/test_collections.py @@ -394,3 +394,23 @@ def test_delete_collection(crawler_auth_headers, default_org_id, crawler_crawl_i headers=crawler_auth_headers, ) assert _second_coll_id not in r.json()["collections"] + + # Make a new empty (no crawls) collection and delete it + r = requests.post( + f"{API_PREFIX}/orgs/{default_org_id}/collections", + headers=crawler_auth_headers, + json={ + "name": "To delete", + "description": "Deleting a collection with no crawls should work.", + }, + ) + assert r.status_code == 200 + data = r.json() + coll_id = data["added"]["id"] + + 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"]