Fix unsetting all collections via PATCH update (#1126)
This commit is contained in:
parent
a9ab17fc61
commit
1aa951132c
@ -167,7 +167,7 @@ class BaseCrawlOps:
|
|||||||
# Update collections then unset from update_values
|
# Update collections then unset from update_values
|
||||||
# We handle these separately due to updates required for collection changes
|
# We handle these separately due to updates required for collection changes
|
||||||
collection_ids = update_values.get("collectionIds")
|
collection_ids = update_values.get("collectionIds")
|
||||||
if collection_ids:
|
if collection_ids is not None:
|
||||||
await self._update_crawl_collections(crawl_id, org, collection_ids)
|
await self._update_crawl_collections(crawl_id, org, collection_ids)
|
||||||
update_values.pop("collectionIds", None)
|
update_values.pop("collectionIds", None)
|
||||||
|
|
||||||
|
@ -810,6 +810,31 @@ def test_update_upload_metadata_all_crawls(admin_auth_headers, default_org_id):
|
|||||||
assert data["name"] == UPDATED_NAME
|
assert data["name"] == UPDATED_NAME
|
||||||
assert data["collectionIds"] == UPDATED_COLLECTION_IDS
|
assert data["collectionIds"] == UPDATED_COLLECTION_IDS
|
||||||
|
|
||||||
|
# Submit patch request to set collections to empty list
|
||||||
|
UPDATED_COLLECTION_IDS = []
|
||||||
|
r = requests.patch(
|
||||||
|
f"{API_PREFIX}/orgs/{default_org_id}/all-crawls/{upload_id}",
|
||||||
|
headers=admin_auth_headers,
|
||||||
|
json={
|
||||||
|
"collectionIds": UPDATED_COLLECTION_IDS,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
data = r.json()
|
||||||
|
assert data["updated"]
|
||||||
|
|
||||||
|
# Verify update was successful
|
||||||
|
r = requests.get(
|
||||||
|
f"{API_PREFIX}/orgs/{default_org_id}/all-crawls/{upload_id}",
|
||||||
|
headers=admin_auth_headers,
|
||||||
|
)
|
||||||
|
assert r.status_code == 200
|
||||||
|
data = r.json()
|
||||||
|
assert sorted(data["tags"]) == sorted(UPDATED_TAGS)
|
||||||
|
assert data["description"] == UPDATED_DESC
|
||||||
|
assert data["name"] == UPDATED_NAME
|
||||||
|
assert data["collectionIds"] == []
|
||||||
|
|
||||||
|
|
||||||
def test_delete_form_upload_from_all_crawls(admin_auth_headers, default_org_id):
|
def test_delete_form_upload_from_all_crawls(admin_auth_headers, default_org_id):
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
|
Loading…
Reference in New Issue
Block a user