Files
ahriman/tests/ahriman/web/views/test_view_ahriman.py
Evgeniy Alekseev 74a244f06c Add tests (#1) (#5)
* 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
2021-03-28 15:30:51 +03:00

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