refactor(providers): address PR #772 review round 3 — hermetic test, lazy logging, defensive-guard tests
- test_registry.py: stub `mistralai.client.Mistral` in `test_registry_mistral_wins_over_ollama`, mirroring the sibling picker test, so the test doesn't depend on the SDK accepting arbitrary keys. - openai.py: convert remaining f-string `logger.info(...)` calls to lazy `%s` formatting, aligning with the pattern in mistral.py and the repo's logging convention. - test_mistral.py: add four tests covering the defensive RuntimeError guards in `embed()` and `_embed_batch_request()` — empty response.data, single null embedding, batch null embedding, and count-mismatch. - docs/configuration.md: add `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` rows to the env-var reference table; they were already mentioned in prose but missing from the table. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
20f1770794
commit
adcf13f082
@@ -108,8 +108,11 @@ def test_registry_openai_wins_over_mistral_and_ollama(clean_provider_env):
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_registry_mistral_wins_over_ollama(clean_provider_env):
|
||||
def test_registry_mistral_wins_over_ollama(clean_provider_env, mocker):
|
||||
"""Mistral takes priority over Ollama when both are configured."""
|
||||
# Stub the Mistral SDK constructor for the same reason as the sibling
|
||||
# picker test — keeps the registry test independent of SDK key validation.
|
||||
mocker.patch("nextcloud_mcp_server.providers.mistral.Mistral")
|
||||
clean_provider_env.setenv("MISTRAL_API_KEY", "mistral-key")
|
||||
clean_provider_env.setenv("OLLAMA_BASE_URL", "http://localhost:11434")
|
||||
_reload_config()
|
||||
|
||||
Reference in New Issue
Block a user