Files
beaver_project/external-connector/tests/test_main.py
steven_li 2cacff4a0f feat(external-connector): 默认连接器提供者改为官方版本
将环境变量 CONNECTOR_PROVIDER 的默认值从 "fake" 改为 "official",
以便在没有明确指定提供者时使用官方的连接器实现。
2026-06-16 10:48:45 +08:00

25 lines
890 B
Python

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"