mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-23 02:39:57 +00:00
* add models tests (#1) also replace single quote to double one to confort PEP docstring + move _check_output to class properties to make it available for mocking * alpm tests implementation * try to replace os with pathlib * update tests for pathlib * fix includes glob and trim version from dependencies * build_tools package tests * repository component tests * add sign tests * complete status tests * handle exceptions in actual_version calls * complete core tests * move configuration to root conftest * application tests * complete application tests * change copyright to more generic one * base web tests * complete web tests * complete testkit also add argument parsers test
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from aiohttp.test_utils import TestClient
|
|
|
|
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
|
|
|
|
|
async def test_get(client: TestClient) -> None:
|
|
"""
|
|
must return valid service status
|
|
"""
|
|
response = await client.get("/api/v1/ahriman")
|
|
status = BuildStatus.from_json(await response.json())
|
|
|
|
assert response.status == 200
|
|
assert status.status == BuildStatusEnum.Unknown
|
|
|
|
|
|
async def test_post(client: TestClient) -> None:
|
|
"""
|
|
must update service status correctly
|
|
"""
|
|
payload = {"status": BuildStatusEnum.Success.value}
|
|
post_response = await client.post("/api/v1/ahriman", json=payload)
|
|
assert post_response.status == 204
|
|
|
|
response = await client.get("/api/v1/ahriman")
|
|
status = BuildStatus.from_json(await response.json())
|
|
|
|
assert response.status == 200
|
|
assert status.status == BuildStatusEnum.Success
|
|
|
|
|
|
async def test_post_exception(client: TestClient) -> None:
|
|
"""
|
|
must raise exception on invalid payload
|
|
"""
|
|
post_response = await client.post("/api/v1/ahriman", json={})
|
|
assert post_response.status == 400
|