test(harness): end-to-end tht ollama ensure via root app
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
"""Tests for the ensure_ollama orchestration (Ollama mocked via injected ops)."""
|
||||
import json as _json
|
||||
from types import SimpleNamespace
|
||||
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from tht.config import EmbeddingsConfig
|
||||
from tht.cli.ollama_cmd import ensure_ollama
|
||||
from tht.cli import ollama_cmd
|
||||
from tht.cli.ollama_cmd import ensure_ollama, ollama_app
|
||||
|
||||
|
||||
def _cfg(**kw):
|
||||
@@ -140,14 +144,6 @@ def test_initial_probe_exception_is_server_error():
|
||||
assert r["ok"] is False and r["stage"] == "server"
|
||||
|
||||
|
||||
import json as _json
|
||||
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from tht.cli.ollama_cmd import ollama_app
|
||||
from tht.cli import ollama_cmd
|
||||
|
||||
|
||||
def _patch(monkeypatch, result):
|
||||
monkeypatch.setattr(ollama_cmd, "_load_config_or_exit", lambda _c: SimpleNamespace(embeddings=object()))
|
||||
monkeypatch.setattr(ollama_cmd, "ensure_ollama", lambda cfg, **kw: result)
|
||||
@@ -179,3 +175,12 @@ def test_cli_registered_on_root_app():
|
||||
res = runner.invoke(app, ["ollama", "--help"])
|
||||
assert res.exit_code == 0
|
||||
assert "ensure" in res.output
|
||||
|
||||
|
||||
def test_cli_root_app_ensure_end_to_end(monkeypatch):
|
||||
from tht.cli import app # root tht app
|
||||
|
||||
_patch(monkeypatch, {"ok": True, "server": "up", "model": "warmed", "model_name": "m"})
|
||||
res = CliRunner().invoke(app, ["ollama", "ensure", "--json"])
|
||||
assert res.exit_code == 0, res.output
|
||||
assert _json.loads(res.output) == {"ok": True, "server": "up", "model": "warmed", "model_name": "m"}
|
||||
|
||||
Reference in New Issue
Block a user