feat: raise 404 in case if package is unknown for logs and patches

This commit is contained in:
2024-01-03 03:26:16 +02:00
parent 1af04448c9
commit f1095fe007
7 changed files with 57 additions and 9 deletions

View File

@ -79,3 +79,16 @@ async def test_get_not_found(client: TestClient, package_ahriman: Package) -> No
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/patches/random")
assert response.status == 404
assert not response_schema.validate(await response.json())
async def test_get_patch_not_found(client: TestClient, package_ahriman: Package) -> None:
"""
must return not found for missing patch
"""
await client.post(f"/api/v1/packages/{package_ahriman.base}",
json={"status": BuildStatusEnum.Success.value, "package": package_ahriman.view()})
response_schema = pytest.helpers.schema_response(PatchView.get, code=404)
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/patches/random")
assert response.status == 404
assert not response_schema.validate(await response.json())

View File

@ -46,6 +46,17 @@ async def test_get(client: TestClient, package_ahriman: Package) -> None:
assert patches == [patch.view()]
async def test_get_not_found(client: TestClient, package_ahriman: Package) -> None:
"""
must return not found for missing package
"""
response_schema = pytest.helpers.schema_response(PatchesView.get, code=404)
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/patches")
assert response.status == 404
assert not response_schema.validate(await response.json())
async def test_post(client: TestClient, package_ahriman: Package) -> None:
"""
must create patch

View File

@ -96,3 +96,14 @@ async def test_get_bad_request(client: TestClient, package_ahriman: Package) ->
response = await client.get(f"/api/v2/packages/{package_ahriman.base}/logs", params={"offset": "offset"})
assert response.status == 400
assert not response_schema.validate(await response.json())
async def test_get_not_found(client: TestClient, package_ahriman: Package) -> None:
"""
must return not found for missing package
"""
response_schema = pytest.helpers.schema_response(LogsView.get, code=404)
response = await client.get(f"/api/v2/packages/{package_ahriman.base}/logs")
assert response.status == 404
assert not response_schema.validate(await response.json())