generated from john/python-template
global theming
This commit is contained in:
+4
-12
@@ -8,19 +8,11 @@ from transcription import __main__ as entrypoint
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_main_passes_constructed_app_to_uvicorn(monkeypatch):
|
||||
"""Non-reload execution keeps the parsed settings instance in the app."""
|
||||
def test_main_uses_cli_factory_import_string(monkeypatch):
|
||||
"""Startup uses an importable factory so Uvicorn owns app creation."""
|
||||
settings = SimpleNamespace(host="127.0.0.1", port=8123, log_level="debug", reload=False)
|
||||
application = object()
|
||||
captured = {}
|
||||
|
||||
def create_app(*, settings: object) -> object:
|
||||
assert settings is expected_settings
|
||||
return application
|
||||
|
||||
expected_settings = settings
|
||||
monkeypatch.setattr(entrypoint, "parse_cli_settings", lambda: settings)
|
||||
monkeypatch.setattr(entrypoint, "create_app", create_app)
|
||||
monkeypatch.setattr(
|
||||
entrypoint.uvicorn,
|
||||
"run",
|
||||
@@ -30,8 +22,8 @@ def test_main_passes_constructed_app_to_uvicorn(monkeypatch):
|
||||
entrypoint.main()
|
||||
|
||||
assert captured == {
|
||||
"application": application,
|
||||
"factory": False,
|
||||
"application": "transcription.__main__:create_cli_app",
|
||||
"factory": True,
|
||||
"host": "127.0.0.1",
|
||||
"port": 8123,
|
||||
"log_level": "debug",
|
||||
|
||||
Reference in New Issue
Block a user