refactor(api): build list, search and session services through one launch_served

This commit is contained in:
imSp4rky
2026-11-29 14:28:47 -07:00
parent e41760c2b3
commit de2ffcb9bd
22 changed files with 444 additions and 280 deletions
+5 -6
View File
@@ -10,6 +10,7 @@ from typing import Any
import click
import pytest
from tests.remote.sessions import launch_session
from unshackle.core.launch import LaunchKeys
pytestmark = pytest.mark.unit
@@ -81,7 +82,7 @@ def rest_relay(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> click.Context
def rest_list(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> click.Context:
handlers, seen = rest_handlers(monkeypatch)
handlers.setup_list_service({}, "EXAMPLE", None, "t")
handlers.launch_served(handlers.LIST, {}, "EXAMPLE", "t", None)
return seen["ctx"]
@@ -101,7 +102,7 @@ def rest_search(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> click.Contex
def rest_session(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> click.Context:
handlers, seen = rest_handlers(monkeypatch)
handlers.create_service_instance("EXAMPLE", "t", {}, None, [], None)
launch_session("EXAMPLE", "t", {})
return seen["ctx"]
@@ -167,11 +168,9 @@ def served_paths(monkeypatch: pytest.MonkeyPatch) -> dict[str, Callable[[dict],
return {
"relay": lambda data: handlers.relay_service(data, "server", None, "t").parent,
"list": lambda data: captured(lambda: handlers.setup_list_service(data, "EXAMPLE", None, "t")),
"list": lambda data: captured(lambda: handlers.launch_served(handlers.LIST, data, "EXAMPLE", "t", None)),
"search": lambda data: captured(lambda: handlers.run_service_search(data, "EXAMPLE", "query")),
"session": lambda data: captured(
lambda: handlers.create_service_instance("EXAMPLE", "t", data, None, [], None)
),
"session": lambda data: captured(lambda: launch_session("EXAMPLE", "t", data)),
}