/ tests / hermes_cli / test_setup_ollama_cloud_force_refresh.py
test_setup_ollama_cloud_force_refresh.py
 1  """Regression: ``hermes setup`` for the ollama-cloud provider must force-refresh
 2  the model cache after the user supplies a key, otherwise the picker keeps
 3  serving a stale cache (models.dev only, no live API probe) for up to an hour.
 4  """
 5  
 6  from __future__ import annotations
 7  
 8  from unittest.mock import patch
 9  
10  
11  def test_setup_ollama_cloud_passes_force_refresh(monkeypatch):
12      """The provider-setup model-fetch for ollama-cloud must pass ``force_refresh=True``."""
13      import hermes_cli.main as main_mod
14      import inspect
15  
16      src = inspect.getsource(main_mod)
17  
18      # Locate the ollama-cloud branch in the provider setup flow.
19      marker = 'provider_id == "ollama-cloud"'
20      assert marker in src, "ollama-cloud branch missing from provider setup"
21      idx = src.index(marker)
22      # The call to fetch_ollama_cloud_models should be within the next ~2000 chars.
23      snippet = src[idx:idx + 2000]
24      assert "fetch_ollama_cloud_models(" in snippet, snippet[:500]
25      assert "force_refresh=True" in snippet, (
26          "ollama-cloud setup must pass force_refresh=True so newly released "
27          "models (e.g. deepseek v4 flash, kimi k2.6) appear the moment the "
28          "user enters their key, not an hour later when the cache TTL expires. "
29          f"Snippet: {snippet[:500]}"
30      )