feat(api): /VERSION single source read at startup + GET /version
This commit is contained in:
22
api/tests/test_version.py
Normal file
22
api/tests/test_version.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
from app.version import VERSION, get_version
|
||||
|
||||
client = TestClient(app)
|
||||
ROOT_VERSION = Path(__file__).resolve().parents[2] / "VERSION"
|
||||
|
||||
|
||||
def test_get_version_matches_file():
|
||||
assert ROOT_VERSION.is_file()
|
||||
assert get_version() == ROOT_VERSION.read_text(encoding="utf-8").strip()
|
||||
|
||||
|
||||
def test_app_version_matches():
|
||||
assert app.version == VERSION == get_version()
|
||||
|
||||
|
||||
def test_version_endpoint():
|
||||
assert client.get("/version").json() == {"version": VERSION}
|
||||
Reference in New Issue
Block a user