Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion selftests/test_connect_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def handler(request: httpx.Request) -> httpx.Response:
if request.method == "GET" and path.endswith("/v1/tags"):
return httpx.Response(200, json=[{"id": "t1", "name": "_vip_test"}])
if request.method == "GET" and path.endswith("/v1/tags/t1/content"):
return httpx.Response(200, json={"results": [{"guid": "a"}, {"guid": "b"}]})
return httpx.Response(200, json=[{"guid": "a"}, {"guid": "b"}])
if request.method == "DELETE":
return httpx.Response(200)
if request.method == "GET":
Expand All @@ -127,6 +127,21 @@ def handler(request: httpx.Request) -> httpx.Response:
assert ("GET", "/__api__/v1/content/b") in calls


def test_list_vip_content_returns_bare_array_from_tag_content_endpoint():
"""GET /v1/tags/{id}/content returns a bare JSON array, not {"results": [...]}."""

def handler(request: httpx.Request) -> httpx.Response:
path = request.url.path
if path.endswith("/v1/tags"):
return httpx.Response(200, json=[{"id": "t1", "name": "_vip_test"}])
if path.endswith("/v1/tags/t1/content"):
return httpx.Response(200, json=[{"guid": "a"}, {"guid": "b"}])
return httpx.Response(404)

cc = _client_with_handler(handler)
assert cc.list_vip_content() == [{"guid": "a"}, {"guid": "b"}]


def test_cleanup_vip_content_raises_when_tag_lookup_fails():
"""A failed tag lookup must raise, not silently report "0 deleted".

Expand Down
3 changes: 2 additions & 1 deletion src/vip/clients/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def list_vip_content(self) -> list[dict[str, Any]]:
tag_id = tags[0]["id"]
resp = self._client.get(f"/v1/tags/{tag_id}/content")
resp.raise_for_status()
return resp.json().get("results", [])
# Unlike the paginated list endpoints, this returns a bare array.
return resp.json()
except Exception as exc:
raise ProductUnreachableError(f"could not list VIP-tagged content: {exc}") from exc

Expand Down
Loading