- Updated the `collect_access_links` function to provide clearer user-facing endpoint labels and notes, particularly for non-tunneled scenarios. - Improved logging messages in the provisioning process to reflect the status of the SwarmUI and Ollama API, enhancing user feedback during setup. - Added human-readable status messages for backend loading and running states, improving clarity during the waiting process. - Updated tests to verify the new behavior and ensure accurate reporting of access links and backend statuses.
50 lines
1.5 KiB
Python
50 lines
1.5 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 "SwarmUI MCP" in labels
|
|
assert "Ollama API" in labels
|
|
assert any("17811" in x.url for x in links)
|
|
|
|
|
|
def test_collect_links_no_tunnel():
|
|
links = collect_access_links(_Cfg(), tunneled=False)
|
|
labels = [x.label for x in links]
|
|
assert "SwarmUI UI" in labels
|
|
assert "Ollama API" in labels
|
|
assert any("17801" in x.url for x in links)
|
|
assert any(x.note == "после tunnel" for x in links)
|
|
assert any(x.label == "Сейчас" for x in links)
|
|
|
|
|
|
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"
|