MembersIn.legal_entity_ids ≤ 500, StatusIn.comment ≤ 1000, OsvFilters.q ≤ 500 (422 со списком ошибок); lock_visible_version проверяет видимость версии до FOR UPDATE. Спека consolidations-api: требование «Границы входных данных». Refs #21 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Claude-Session: cedd7915-2efe-41e5-988c-a9117033598b
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
"""Верхние границы входов консолидаций (spec consolidations-api «Границы входных данных», M-6 из #21): превышение —
|
||
422 со списком ошибок валидации (формат приложения: `detail[].loc/msg`) до обращения к БД."""
|
||
|
||
import uuid
|
||
|
||
import pytest
|
||
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
||
from src.schemas.consolidations import MAX_MEMBERS, MAX_OSV_QUERY, MAX_STATUS_COMMENT
|
||
from tests.conftest import AuthClientFactory
|
||
|
||
HTTP_UNPROCESSABLE = 422
|
||
KA_RF = "ka_rf@armka.local"
|
||
VERSIONS = "/consolidations/versions"
|
||
|
||
|
||
@pytest.mark.integration
|
||
async def test_members_over_limit_is_422(auth_client: AuthClientFactory, seeded: AsyncSession) -> None: # noqa: ARG001
|
||
client = await auth_client(KA_RF)
|
||
ids = [str(uuid.uuid4()) for _ in range(MAX_MEMBERS + 1)]
|
||
|
||
response = await client.put(f"{VERSIONS}/{uuid.uuid4()}/members", json={"legal_entity_ids": ids})
|
||
|
||
assert response.status_code == HTTP_UNPROCESSABLE
|
||
assert response.json()["detail"][0]["loc"] == ["body", "legal_entity_ids"]
|
||
|
||
|
||
@pytest.mark.integration
|
||
async def test_status_comment_over_limit_is_422(auth_client: AuthClientFactory, seeded: AsyncSession) -> None: # noqa: ARG001
|
||
client = await auth_client(KA_RF)
|
||
|
||
response = await client.post(
|
||
f"{VERSIONS}/{uuid.uuid4()}/status", json={"to_status": "CANCELLED", "comment": "а" * (MAX_STATUS_COMMENT + 1)}
|
||
)
|
||
|
||
assert response.status_code == HTTP_UNPROCESSABLE
|
||
assert response.json()["detail"][0]["loc"] == ["body", "comment"]
|
||
|
||
|
||
@pytest.mark.integration
|
||
async def test_osv_query_over_limit_is_422(auth_client: AuthClientFactory, seeded: AsyncSession) -> None: # noqa: ARG001
|
||
client = await auth_client(KA_RF)
|
||
|
||
response = await client.get(f"{VERSIONS}/{uuid.uuid4()}/osv", params={"q": "а" * (MAX_OSV_QUERY + 1)})
|
||
|
||
assert response.status_code == HTTP_UNPROCESSABLE
|
||
assert response.json()["detail"][0]["loc"] == ["query", "q"]
|