Refactor access card handling and update CLI output for tunnel operations
- Integrated `print_access_card` functionality into the `up` command for both tunneled and non-tunneled scenarios. - Removed the deprecated `print_mcp_snippet` function from the session management flow. - Updated the `tunnel_forwards` function to streamline port handling for LLM runtimes. - Enhanced test cases to reflect changes in access card printing and MCP snippet logging.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from gpu_rent.access_card import collect_access_links, mcp_snippet_lines
|
||||
|
||||
|
||||
class _Cfg:
|
||||
swarmui_local_port = 17801
|
||||
llm_runtime = "ollama"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
|
||||
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)
|
||||
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)
|
||||
@@ -6,6 +6,9 @@ class _Cfg:
|
||||
boot_snapshot_name = "gpu-rent-boot-ok"
|
||||
swarmui_local_port = 17801
|
||||
notify_ready = True
|
||||
llm_runtime = "none"
|
||||
ollama_local_port = 17811
|
||||
llamacpp_local_port = 17812
|
||||
|
||||
|
||||
def test_ensure_boot_snapshot_skips_existing():
|
||||
@@ -66,10 +69,15 @@ def test_ensure_boot_snapshot_creates(monkeypatch):
|
||||
assert got.status == "available"
|
||||
|
||||
|
||||
def test_mcp_snippet(capsys):
|
||||
def test_mcp_snippet(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"gpu_rent.access_card.load_state",
|
||||
lambda: type("S", (), {"notes": {}})(),
|
||||
)
|
||||
logs = []
|
||||
print_mcp_snippet(_Cfg(), logs.append)
|
||||
text = "\n".join(logs)
|
||||
assert "17801/mcp" in text
|
||||
assert "gpu-rent tunnel" in text
|
||||
assert "mcp.json" in text
|
||||
assert "SwarmUI UI" in text
|
||||
assert "gpu-rent stop" in text
|
||||
|
||||
@@ -53,7 +53,6 @@ def _mock_bind(monkeypatch):
|
||||
lambda conn, boot_volume_id, cfg, log: None,
|
||||
)
|
||||
monkeypatch.setattr("gpu_rent.session.notify_ready", lambda cfg, log: None)
|
||||
monkeypatch.setattr("gpu_rent.session.print_mcp_snippet", lambda cfg, log: None)
|
||||
|
||||
|
||||
def test_cmd_up_refuses_zero_gpu_quota(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user