feat: publish canonical source contracts
All checks were successful
Mostovik Backend CI/CD / Tests and lint (push) Successful in 3m3s
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Successful in 5m2s
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been skipped
Mostovik Backend CI/CD / Deploy dev (push) Successful in 2m53s

This commit is contained in:
Aleksandr Meshchryakov
2026-09-24 14:46:08 +02:00
parent 0ad4e9fa05
commit 553d787076
5 changed files with 1956 additions and 15 deletions

View File

@@ -36,7 +36,7 @@ def test_discriminated_records_keep_named_ordering_and_old_operations(contract):
schemas = contract["components"]["schemas"]
for name in ("OrganizationSourceRecord", "OrganizationSourceRecordList"):
record = schemas[name]
assert len(record["oneOf"]) == 4
assert len(record["oneOf"]) == 6
assert record["discriminator"]["propertyName"] == "source_group"
for group, record_type in (
("budget_process_registry", "budget_registry_organization"),
@@ -75,6 +75,36 @@ def test_discriminated_records_keep_named_ordering_and_old_operations(contract):
)
def test_extended_source_contracts_document_full_page_and_typed_errors(contract):
schemas = contract["components"]["schemas"]
for kind, payload_name in (
("List", "IntegratedStructureListPayload"),
("Detail", "IntegratedStructureDetailPayload"),
):
variant = schemas[f"IntegratedStructureRecord{kind}"]
assert variant["properties"]["payload"]["$ref"].endswith(payload_name)
fed_detail = schemas["FedresursCompanyProfileRecordDetail"]
assert fed_detail["properties"]["payload"]["$ref"].endswith(
"FedresursCompanyProfileDetailPayload"
)
assert (
"rendered_page" in schemas["FedresursCompanyProfileDetailPayload"]["properties"]
)
paths = contract["paths"]
attachment = paths[
"/api/v2/organization-source-records/{uid}/documents/{document_id}/attachment/"
]["get"]
assert "application/rtf" in attachment["responses"]["200"]["content"]
assert attachment["responses"]["409"]["content"]["application/json"]["schema"][
"$ref"
].endswith("AttachmentUnavailableError")
upload = paths["/api/v1/parsers/upload/fedresurs_company_profile/"]["post"]
assert upload["responses"]["405"]["content"]["application/json"]["schema"][
"$ref"
].endswith("FedresursUploadNotSupportedError")
@pytest.mark.parametrize(
("source", "list_serializer", "detail_serializer"),
[