test: port the v1 endpoint and browser tests to v2

HTTP tests against a running controller (make test-api HOST=ip). They
snapshot every collection through /db and restore it afterwards. v1
behaviour v2 does not have yet is marked as a strict xfail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-03 01:33:08 +13:00
1 parent 9d628aa3c8
commit 4b42391a46
15 files changed
+2055 -1

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import uuid
import pytest
def unique(prefix):
return f"{prefix}-{uuid.uuid4().hex[:8]}"
def new_id(resp):
"""Id of a created record: replies are {"<id>": record} or a record with "id"."""
data = resp.json()
if "id" in data and not isinstance(data["id"], dict):
return str(data["id"])
return str(next(iter(data)))
def find_id_by_field(listing, field, value):
for obj_id, data in listing.items():
if isinstance(data, dict) and data.get(field) == value:
return str(obj_id)
raise AssertionError(f"Could not find id for {field}={value!r}")
def missing(feature):
"""Mark a test for v1 behaviour v2 does not have yet; strict, so it fails once the feature lands."""
return pytest.mark.xfail(strict=True, reason=f"v2: {feature} not implemented")