b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
from hermes_cli import nous_auth_keepalive as keepalive
|
|
|
|
|
|
def test_keepalive_refreshes_stale_pool_entry(monkeypatch):
|
|
class _Entry:
|
|
access_token = "pooled-access-token"
|
|
expires_at = "2000-01-01T00:00:00+00:00"
|
|
agent_key = ""
|
|
agent_key_expires_at = None
|
|
scope = "inference:invoke"
|
|
|
|
class _Pool:
|
|
refreshed = False
|
|
|
|
def has_credentials(self):
|
|
return True
|
|
|
|
def select(self):
|
|
return _Entry()
|
|
|
|
def try_refresh_current(self):
|
|
self.refreshed = True
|
|
return _Entry()
|
|
|
|
pool = _Pool()
|
|
monkeypatch.setattr("agent.credential_pool.load_pool", lambda provider: pool)
|
|
|
|
assert keepalive.refresh_nous_auth_keepalive_once() is True
|
|
assert pool.refreshed is True
|
|
|
|
|
|
def test_keepalive_falls_back_to_singleton_state(monkeypatch):
|
|
calls = []
|
|
|
|
class _Pool:
|
|
def has_credentials(self):
|
|
return False
|
|
|
|
def _resolve_nous_runtime_credentials(**kwargs):
|
|
calls.append(kwargs)
|
|
return {
|
|
"provider": "nous",
|
|
"api_key": "fresh-agent-key",
|
|
"base_url": "https://inference-api.nousresearch.com/v1",
|
|
}
|
|
|
|
monkeypatch.setattr("agent.credential_pool.load_pool", lambda provider: _Pool())
|
|
monkeypatch.setattr(
|
|
keepalive,
|
|
"get_provider_auth_state",
|
|
lambda provider: {"access_token": "stored-access-token"},
|
|
)
|
|
monkeypatch.setattr(
|
|
keepalive,
|
|
"resolve_nous_runtime_credentials",
|
|
_resolve_nous_runtime_credentials,
|
|
)
|
|
|
|
assert keepalive.refresh_nous_auth_keepalive_once(timeout_seconds=15.0) is True
|
|
assert calls == [{"timeout_seconds": 15.0}]
|