test: guard optional hermes_cli import in fail-closed pricing test
The new test_openrouter_free_tier_pricing_fails_closed did an unguarded 'from hermes_cli import models', but hermes_cli (the agent package) is an optional dependency not installed in the WebUI CI test environment, so the test failed with ModuleNotFoundError on 4-5 shards (master green, PR head red). Wrap the import in the same try/except guard the sibling tests in this file already use — when hermes_cli is present we force its live-fetch to empty so the fail-closed static path is exercised; when absent, that static path is already the only one and the api/config.py fix under test still runs via the mocked urlopen. Verified: 10/10 with hermes_cli, 5/5 with it blocked. Co-authored-by: igorroncevic <igorroncevic@users.noreply.github.com>
This commit is contained in:
1 parent
dea5e8a96d
commit
2dc6530f2b
1 file changed
+11
-4
@@ -167,10 +167,17 @@ def test_openrouter_free_tier_pricing_fails_closed(
|
||||
lambda *_args, **_kwargs: _FakeResponse(fake_payload),
|
||||
)
|
||||
|
||||
from hermes_cli import models as hermes_models
|
||||
|
||||
monkeypatch.setattr(hermes_models, "fetch_openrouter_models", lambda **_kwargs: [])
|
||||
monkeypatch.setattr(hermes_models, "provider_model_ids", lambda *_args, **_kwargs: [])
|
||||
# hermes_cli (the agent package) is an optional dependency and is not
|
||||
# installed in the WebUI CI test environment. Force its live-fetch to
|
||||
# return empty when present so the fail-closed static path is exercised;
|
||||
# when absent, that static path is already the only one — mirror the
|
||||
# try/except guard the sibling tests in this file use.
|
||||
try:
|
||||
from hermes_cli import models as hermes_models
|
||||
monkeypatch.setattr(hermes_models, "fetch_openrouter_models", lambda **_kwargs: [])
|
||||
monkeypatch.setattr(hermes_models, "provider_model_ids", lambda *_args, **_kwargs: [])
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
grouped = _get_grouped_models()
|
||||
openrouter_group = next(
|
||||
|
||||
Reference in new issue
Block a user