generated from coulomb/repo-seed
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from http import HTTPStatus
|
|
import shutil
|
|
|
|
from info_tech_canon.api import _route
|
|
from info_tech_canon.service import DEFAULT_INFOSPACE_ROOT, generate_indexes
|
|
|
|
|
|
def test_api_route_inspect() -> None:
|
|
status, payload = _route("/inspect", {}, None)
|
|
|
|
assert status == HTTPStatus.OK
|
|
assert payload["ok"] is True
|
|
assert payload["infospace"]["slug"] == "canon"
|
|
|
|
|
|
def test_api_route_validate() -> None:
|
|
status, payload = _route("/validate", {}, None)
|
|
|
|
assert status == HTTPStatus.OK
|
|
assert payload["ok"] is True
|
|
|
|
|
|
def test_api_route_unknown_endpoint() -> None:
|
|
status, payload = _route("/missing", {}, None)
|
|
|
|
assert status == HTTPStatus.NOT_FOUND
|
|
assert payload["ok"] is False
|
|
assert payload["error"]["code"] == "not_found"
|
|
|
|
|
|
def test_api_route_reads_generated_view(tmp_path) -> None:
|
|
root = tmp_path / "infospace"
|
|
shutil.copytree(DEFAULT_INFOSPACE_ROOT, root)
|
|
generate_indexes(root)
|
|
|
|
status, payload = _route("/views/by-standard.md", {}, root)
|
|
|
|
assert status == HTTPStatus.OK
|
|
assert payload["ok"] is True
|
|
assert payload["generated"] is True
|
|
assert "# By Standard" in payload["content"]
|