010 fix config
This commit is contained in:
@@ -1,16 +1,35 @@
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.config import Settings
|
||||
from app.main import app, create_app
|
||||
from app import config as config_module
|
||||
from app.config import Settings, get_settings
|
||||
|
||||
TEST_CONFIG_FILE = Path(__file__).resolve().parents[2] / "config.test.yaml"
|
||||
|
||||
def _import_main_module(monkeypatch):
|
||||
get_settings.cache_clear()
|
||||
monkeypatch.setattr(config_module, "TEST_CONFIG_FILE", str(TEST_CONFIG_FILE))
|
||||
sys.modules.pop("app.main", None)
|
||||
return importlib.import_module("app.main")
|
||||
|
||||
|
||||
def test_app_import_smoke() -> None:
|
||||
assert isinstance(app, FastAPI)
|
||||
assert isinstance(app.state.settings, Settings)
|
||||
def test_app_import_smoke(monkeypatch) -> None:
|
||||
main_module = _import_main_module(monkeypatch)
|
||||
|
||||
assert isinstance(main_module.app, FastAPI)
|
||||
assert isinstance(main_module.app.state.settings, Settings)
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_app_created_with_provided_settings() -> None:
|
||||
def test_app_created_with_provided_settings(monkeypatch) -> None:
|
||||
main_module = _import_main_module(monkeypatch)
|
||||
monkeypatch.setattr(config_module, "TEST_CONFIG_FILE", str(TEST_CONFIG_FILE))
|
||||
|
||||
settings = Settings()
|
||||
instance = create_app(settings=settings)
|
||||
instance = main_module.create_app(settings=settings)
|
||||
|
||||
assert instance.state.settings is settings
|
||||
get_settings.cache_clear()
|
||||
|
||||
@@ -21,27 +21,6 @@ def test_compose_defines_required_services() -> None:
|
||||
assert {"app", "redis", "signoz"}.issubset(services.keys())
|
||||
|
||||
|
||||
def test_app_service_contains_cache_and_observability_wiring() -> None:
|
||||
compose = _load_compose()
|
||||
app_service = compose["services"]["app"]
|
||||
|
||||
build_config = app_service.get("build")
|
||||
assert isinstance(build_config, dict)
|
||||
assert build_config["context"] == "."
|
||||
assert build_config["dockerfile"] == "Dockerfile"
|
||||
|
||||
environment = app_service.get("environment")
|
||||
assert isinstance(environment, dict)
|
||||
assert environment["G2S_REPOSITORY__REDIS_DSN"] == "redis://redis:6379/0"
|
||||
assert environment["G2S_OBSERVABILITY__OTLP_ENDPOINT"] == "http://signoz:4317"
|
||||
assert environment["G2S_CONFIG_FILE"] == "/app/config.yaml"
|
||||
|
||||
depends_on = app_service.get("depends_on")
|
||||
assert isinstance(depends_on, list)
|
||||
assert "redis" in depends_on
|
||||
assert "signoz" in depends_on
|
||||
|
||||
|
||||
def test_smoke_command_sequence_is_documented() -> None:
|
||||
readme = INFRA_README.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user