/
systemsstrategyy
/
Treker
Обзор
Документация
Войти
/
systemsstrategyy
/
Treker
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
tests/modules/views/test_openapi_problem_views.py
84 строки
3 KB
SystemsStrategy
Initial import
02 июл 2026, 15:15
02 июл 2026, 15:15
9624ed1
Код
Авторство
О чём код?
"""Schemathesis findings #60 — Problem+JSON для views (3 endpoints). Финальный sub-domain issue #60: - GET /api/v1/spaces/{space_uid}/views/kanban - GET /api/v1/spaces/{space_uid}/views/calendar - GET /api/v1/spaces/{space_uid}/views/list Все resource-based — ожидаем 401/403/404 с application/problem+json. """ from __future__ import annotations from typing import Any import pytest from api.main import app VIEWS_ENDPOINTS: list[tuple[str, str]] = [ ("/api/v1/spaces/{space_uid}/views/kanban", "get"), ("/api/v1/spaces/{space_uid}/views/calendar", "get"), ("/api/v1/spaces/{space_uid}/views/list", "get"), ] @pytest.fixture(scope="module") def openapi_schema() -> dict[str, Any]: return app.openapi() def _operation(schema: dict[str, Any], path: str, method: str) -> dict[str, Any]: paths = schema.get("paths", {}) assert path in paths, f"Path {path} not found in OpenAPI schema" methods = paths[path] assert method in methods, ( f"Method {method.upper()} not registered for {path} (available: {list(methods)})" ) return dict(methods[method]) @pytest.mark.parametrize(("path", "method"), VIEWS_ENDPOINTS) def test_endpoint_declares_401_problem_json( openapi_schema: dict[str, Any], path: str, method: str ) -> None: op = _operation(openapi_schema, path, method) responses = op.get("responses", {}) assert "401" in responses, ( f"{method.upper()} {path} не декларирует 401 (schemathesis: Undocumented HTTP status code)" ) content = responses["401"].get("content", {}) assert "application/problem+json" in content, ( f"{method.upper()} {path} 401-response не объявляет application/problem+json" ) @pytest.mark.parametrize(("path", "method"), VIEWS_ENDPOINTS) def test_endpoint_declares_403_problem_json( openapi_schema: dict[str, Any], path: str, method: str ) -> None: op = _operation(openapi_schema, path, method) responses = op.get("responses", {}) assert "403" in responses, ( f"{method.upper()} {path} не декларирует 403 (schemathesis: Undocumented HTTP status code)" ) content = responses["403"].get("content", {}) assert "application/problem+json" in content, ( f"{method.upper()} {path} 403-response не объявляет application/problem+json" ) @pytest.mark.parametrize(("path", "method"), VIEWS_ENDPOINTS) def test_endpoint_declares_404_problem_json( openapi_schema: dict[str, Any], path: str, method: str ) -> None: op = _operation(openapi_schema, path, method) responses = op.get("responses", {}) assert "404" in responses, ( f"{method.upper()} {path} не декларирует 404 (schemathesis: Undocumented HTTP status code)" ) content = responses["404"].get("content", {}) assert "application/problem+json" in content, ( f"{method.upper()} {path} 404-response не объявляет application/problem+json" )