Skip to content

Commit e5556f4

Browse files
committed
check potential issue with change of collection body
1 parent 202b8a2 commit e5556f4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/resources/test_item.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,3 +1722,43 @@ async def test_item_search_freetext(app_client, load_test_data, load_test_collec
17221722
params={"q": "yo"},
17231723
)
17241724
assert resp.json()["numberReturned"] == 0
1725+
1726+
1727+
@pytest.mark.asyncio
1728+
async def test_item_asset_change(app_client, load_test_data):
1729+
# load collection
1730+
data = load_test_data("test2_collection.json")
1731+
collection_id = data["id"]
1732+
1733+
resp = await app_client.post("/collections", json=data)
1734+
assert "item_assets" in data
1735+
assert resp.status_code == 201
1736+
assert "item_assets" in resp.json()
1737+
1738+
# load items
1739+
test_item = load_test_data("test2_item.json")
1740+
resp = await app_client.post(f"/collections/{collection_id}/items", json=test_item)
1741+
assert resp.status_code == 201
1742+
1743+
# check list of items
1744+
resp = await app_client.get(
1745+
f"/collections/{collection_id}/items", params={"limit": 1}
1746+
)
1747+
assert resp.json()["numberReturned"] == 1
1748+
assert resp.status_code == 200
1749+
1750+
# remove item_assets in collection
1751+
operations = [{"op": "remove", "path": "/item_assets"}]
1752+
resp = await app_client.patch(f"/collections/{collection_id}", json=operations)
1753+
assert resp.status_code == 200
1754+
1755+
# make sure item_assets is not in collection response
1756+
resp = await app_client.get(f"/collections/{collection_id}")
1757+
assert resp.status_code == 200
1758+
assert "item_assets" not in resp.json()
1759+
1760+
resp = await app_client.get(
1761+
f"/collections/{collection_id}/items", params={"limit": 1}
1762+
)
1763+
assert resp.json()["numberReturned"] == 1
1764+
assert resp.status_code == 200

0 commit comments

Comments
 (0)