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>
28 lines
810 B
Python
28 lines
810 B
Python
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")
|