from __future__ import annotations from external_connector import main def test_build_app_defaults_to_official_provider(monkeypatch, tmp_path) -> None: monkeypatch.delenv("CONNECTOR_PROVIDER", raising=False) monkeypatch.setenv("CONNECTOR_HOME", str(tmp_path)) app = main.build_app() health = next(route.endpoint for route in app.routes if route.path == "/health")() assert health["providerId"] == "composite" assert [provider["providerId"] for provider in health["providers"]] == ["weixin_ilink", "feishu_bot"] def test_build_app_allows_explicit_fake_provider(monkeypatch, tmp_path) -> None: monkeypatch.setenv("CONNECTOR_PROVIDER", "fake") monkeypatch.setenv("CONNECTOR_HOME", str(tmp_path)) app = main.build_app() health = next(route.endpoint for route in app.routes if route.path == "/health")() assert health["providerId"] == "fake"