Files
gpu-rent/tests/test_access_card.py
T
Leonid PershinandCursor 03ba4cb6ed Seed Assistent personas as overlay folders and tighten Ollama/Assistent glue.
gpu-rent now writes personas/<id>/ on the VM (not legacy personas.json), adds seed-personas/doctor checks, and shortens mid/high keep-alive now that Assistent parks the LLM before Generate.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 01:00:14 +03:00

70 lines
2.2 KiB
Python

from gpu_rent.access_card import collect_access_links, mcp_snippet_lines, render_access_panel
class _Cfg:
swarmui_local_port = 17801
llm_runtime = "ollama"
ollama_local_port = 17811
enable_swarmui = True
def test_collect_links_swarm_and_ollama(monkeypatch):
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type("S", (), {"notes": {"llm_runtime": "ollama"}})(),
)
links = collect_access_links(_Cfg(), tunneled=True)
labels = [x.label for x in links]
assert "SwarmUI UI" in labels
assert "Assistent" in labels
assert "SwarmUI MCP" in labels
assert "Ollama API" in labels
assert any(x.label == "Assistent" and "вкладка" in x.note for x in links)
def test_collect_links_no_tunnel():
links = collect_access_links(_Cfg(), tunneled=False)
assert links[0].url.startswith("gpu-rent tunnel")
def test_mcp_snippet_json():
lines = mcp_snippet_lines(_Cfg())
assert any("17801/mcp" in line for line in lines)
def test_access_panel_red_when_killer_failed(monkeypatch):
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type(
"S",
(),
{"notes": {"idle_killer": "failed", "idle_killer_error": "no cred"}},
)(),
)
panel = render_access_panel(_Cfg(), tunneled=True)
assert panel.border_style == "red"
def test_access_panel_hides_stale_llm_error_when_ollama_ok(monkeypatch):
monkeypatch.setattr(
"gpu_rent.access_card.load_state",
lambda: type(
"S",
(),
{
"notes": {
"llm_error": "Ollama /api/tags без моделей",
"stack_vm": [
{
"name": "ollama",
"ok": True,
"detail": "1 models (huihui_ai/qwen3-vl-abliterated:8b-instruct)",
}
],
}
},
)(),
)
panel = render_access_panel(_Cfg(), tunneled=True)
assert panel.border_style != "red"