api: update client models to API v2.2.7 schema

parent ead56bb9
......@@ -4,3 +4,4 @@ __pycache__/
dist/
build/
.venv/
appstream/
......@@ -27,6 +27,7 @@ async def test_export_oval_branches(client):
assert result.branches
@pytest.mark.timeout(120)
async def test_export_oval_info(client):
result = await client.api.errata.export.oval.info(Branch.p11)
assert isinstance(result, bytes)
......
import pytest
from altrepo.api.errors import DataNotFoundError
from altrepo.api.types import Branch
......@@ -66,7 +67,12 @@ async def test_all_pkgsets_with_src_count(client):
async def test_beehive_errors_by_maintainer(client):
result = await client.api.site.beehive_errors_by_maintainer(Branch.sisyphus, "fiersik")
try:
result = await client.api.site.beehive_errors_by_maintainer(
Branch.sisyphus, "fiersik"
)
except DataNotFoundError:
pytest.skip("maintainer has no current beehive errors")
assert result
......
......@@ -39,7 +39,8 @@ async def test_progress_last_tasks(client):
async def test_build_dependency_set(client, task_id):
result = await client.api.task.build_dependency_set(task_id)
assert result.id == task_id
assert result.length >= 0
assert result.packages is not None
async def test_task_info(client, task_id):
......
import ast
import json
from pathlib import Path
from pydantic import BaseModel
from altrepo.api import models
ROOT = Path(__file__).resolve().parents[1]
def _openapi():
return json.loads((ROOT / "openapi.json").read_text())
def _normalize_path(path: str, openapi_paths: set[str]) -> str:
if "{}" not in path:
return path
parts = path.split("/")
candidates = []
for candidate in openapi_paths:
candidate_parts = candidate.split("/")
if len(parts) != len(candidate_parts):
continue
if all(
(part == "{}" and other.startswith("{") and other.endswith("}"))
or part == other
for part, other in zip(parts, candidate_parts)
):
candidates.append(candidate)
return candidates[0] if len(candidates) == 1 else path
def test_all_openapi_schemas_have_models():
schema_names = set(_openapi()["components"]["schemas"])
model_names = {
name
for name, value in vars(models).items()
if isinstance(value, type)
and (issubclass(value, BaseModel) or name in schema_names)
}
assert schema_names <= model_names
def test_client_endpoint_paths_match_openapi():
openapi_paths = set(_openapi()["paths"])
tree = ast.parse((ROOT / "altrepo/api/methods.py").read_text())
client_paths = set()
for node in ast.walk(tree):
if not isinstance(node, ast.Call):
continue
if not isinstance(node.func, ast.Attribute):
continue
if node.func.attr not in {"get", "post", "get_text", "get_bytes"}:
continue
if not node.args:
continue
arg = node.args[0]
if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
value = arg.value
elif isinstance(arg, ast.JoinedStr):
value = "".join(
part.value if isinstance(part, ast.Constant) else "{}"
for part in arg.values
)
else:
continue
if value.startswith("/"):
client_paths.add(_normalize_path(value, openapi_paths))
assert client_paths - openapi_paths == set()
assert (openapi_paths - client_paths) <= {"/site/all_maintainers"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment