Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions deeptutor/services/session/sqlite_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def __init__(self, db_path: Path | None = None, *, in_memory: bool = False) -> N
# destroyed the instant no connection is open. The keep-alive
# connection below stays open for the store's lifetime to pin it.
# A unique name keeps two in-memory stores from sharing one cache.
self.db_path = (
f"file:deeptutor-mem-{uuid.uuid4().hex}?mode=memory&cache=shared"
)
self.db_path = f"file:deeptutor-mem-{uuid.uuid4().hex}?mode=memory&cache=shared"
self._keepalive = sqlite3.connect(self.db_path, uri=True)
self._lock = asyncio.Lock()
self._initialize()
Expand Down
12 changes: 3 additions & 9 deletions tests/api/test_settings_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,14 @@ async def test_mineru_settings_roundtrip_redacts_token(


@pytest.mark.asyncio
async def test_mineru_token_is_environment_only(
monkeypatch: pytest.MonkeyPatch, tmp_path
) -> None:
async def test_mineru_token_is_environment_only(monkeypatch: pytest.MonkeyPatch, tmp_path) -> None:
service = RuntimeSettingsService(
tmp_path / "settings", process_env={"MINERU_API_TOKEN": "env-tok"}
)
monkeypatch.setattr(settings_router, "get_runtime_settings_service", lambda: service)

# The token always comes from the env var, never from the update request.
await settings_router.update_mineru_settings(
settings_router.MinerUSettingsUpdate(mode="cloud")
)
await settings_router.update_mineru_settings(settings_router.MinerUSettingsUpdate(mode="cloud"))
assert service.load_mineru()["api_token"] == "env-tok"
# Nothing secret hit the disk.
assert service.load_mineru(include_process_overrides=False)["api_token"] == ""
Expand Down Expand Up @@ -623,9 +619,7 @@ async def _fake_fetch(binding: str, base_url: str, api_key: str | None = None):
monkeypatch.setattr(factory_module, "fetch_models", _fake_fetch)

response = await settings_router.fetch_models_from_provider(
settings_router.FetchModelsPayload(
binding="OpenAI", base_url="https://api.example.com/v1"
)
settings_router.FetchModelsPayload(binding="OpenAI", base_url="https://api.example.com/v1")
)

assert response == {
Expand Down
8 changes: 2 additions & 6 deletions tests/api/test_system_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@


def _stub_status(monkeypatch, *, api_key: str, provider_mode: str = "standard") -> None:
monkeypatch.setattr(
system_router, "get_current_user", lambda: SimpleNamespace(is_admin=True)
)
monkeypatch.setattr(system_router, "get_current_user", lambda: SimpleNamespace(is_admin=True))
monkeypatch.setattr(
system_router,
"get_llm_config",
lambda: SimpleNamespace(
model="gpt-4o-mini", api_key=api_key, provider_mode=provider_mode
),
lambda: SimpleNamespace(model="gpt-4o-mini", api_key=api_key, provider_mode=provider_mode),
)
monkeypatch.setattr(
system_router,
Expand Down
8 changes: 2 additions & 6 deletions tests/services/config/test_provider_runtime_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def test_empty_catalog_llm_key_resolves_openai_from_env(monkeypatch) -> None:
monkeypatch.setenv("OPENAI_API_KEY", "sk-env-real")
empty = {
"version": 1,
"services": {
"llm": {"active_profile_id": None, "active_model_id": None, "profiles": []}
},
"services": {"llm": {"active_profile_id": None, "active_model_id": None, "profiles": []}},
}
cfg = resolve_llm_runtime_config(empty)
assert cfg.provider_name == "openai"
Expand All @@ -84,9 +82,7 @@ def test_empty_catalog_llm_key_never_sentinel_for_openai(monkeypatch) -> None:
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
empty = {
"version": 1,
"services": {
"llm": {"active_profile_id": None, "active_model_id": None, "profiles": []}
},
"services": {"llm": {"active_profile_id": None, "active_model_id": None, "profiles": []}},
}
cfg = resolve_llm_runtime_config(empty)
assert cfg.provider_name == "openai"
Expand Down
4 changes: 1 addition & 3 deletions tests/services/demo/test_rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def advance(self, seconds: float) -> None:


def _limiter(clock: _FakeClock, *, per_min: int = 3, per_hour: int = 100) -> DemoRateLimiter:
return DemoRateLimiter(
enabled=True, per_min=per_min, per_hour=per_hour, time_fn=clock
)
return DemoRateLimiter(enabled=True, per_min=per_min, per_hour=per_hour, time_fn=clock)


def test_allows_within_per_minute_then_denies_next():
Expand Down
Loading