Files
agentic-mobile-control/apps/cloud-api/tests/test_app.py
T

34 lines
891 B
Python

from __future__ import annotations
from fastapi.testclient import TestClient
from cloud_api.app import create_app
from cloud.control_config import CloudControlConfig
def test_create_app_returns_independent_cloud_application() -> None:
app = create_app()
assert app.title == "Device Cloud API"
assert callable(create_app)
def test_cloud_application_owns_database_lifecycle() -> None:
events: list[str] = []
class FakeDatabase:
def close(self) -> None:
events.append("closed")
fake_database = FakeDatabase()
app = create_app(
config=CloudControlConfig(database_url="sqlite:///:memory:"),
database_factory=lambda _config: fake_database, # type: ignore[arg-type,return-value]
)
with TestClient(app):
assert app.state.database is fake_database
assert events == []
assert events == ["closed"]