feat: implement lab3 load balancing and idempotency

This commit is contained in:
Fedoroff
2026-10-27 20:34:22 +03:00
parent 0ab3a341aa
commit 35ae6f722e
43 changed files with 3045 additions and 42 deletions
+6 -3
View File
@@ -14,7 +14,7 @@ import uuid
ROOT = Path(__file__).resolve().parents[1]
LAB = json.loads((ROOT / 'lab.json').read_text())['number']
SPEC = json.loads((ROOT / 'contracts/openapi.json').read_text())
SPEC = json.loads((ROOT / 'contracts/openapi.json').read_text(encoding='utf-8'))
class Failure(AssertionError):
pass
@@ -24,11 +24,14 @@ def check(condition, message):
raise Failure(message)
def timestamp(value):
check(isinstance(value, str) and value.endswith('Z'), 'timestamp must be UTC ending in Z')
check(
isinstance(value, str) and value.endswith('Z'),
'timestamp must be UTC ending in Z'
)
try:
return dt.datetime.fromisoformat(value[:-1] + '+00:00')
except ValueError as exc:
raise Failure('invalid RFC3339 timestamp') from exc
raise Failure(f'invalid RFC3339 timestamp: {value!r}') from exc
def validate(value, schema, where='response'):
"""Validate the JSON Schema subset used by the supplied contract, not arbitrary OpenAPI."""