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
@@ -6,6 +6,7 @@ from types import SimpleNamespace
import pytest
from tests.remote.sessions import stub_service_build
from unshackle.core.api import handlers, job_admission, key_policy
from unshackle.core.api.errors import APIError
from unshackle.core.remote_protocol import APIErrorCode
@@ -166,7 +167,7 @@ def test_non_string_client_region_rejected(monkeypatch, key):
assert exc_info.value.error_code == APIErrorCode.INVALID_INPUT
def test_setup_list_service_threads_request(monkeypatch):
def test_a_list_launch_threads_the_request(monkeypatch):
"""A regression that stops passing the request through would re-open the proxy gate."""
seen = {}
@@ -187,7 +188,7 @@ def test_setup_list_service_threads_request(monkeypatch):
monkeypatch.setattr("unshackle.core.login.get_credentials", lambda service, profile: None)
req = request("plainkey")
handlers.setup_list_service({}, "EXAMPLE", None, "some-title", req)
handlers.launch_served(handlers.LIST, {}, "EXAMPLE", "some-title", None, req)
assert seen["request"] is req
assert seen["authenticated"]
@@ -359,7 +360,7 @@ def test_session_create_builds_service_off_the_event_loop(monkeypatch):
monkeypatch.setattr(handlers, "server_account_for", lambda *args: False)
monkeypatch.setattr(handlers.Services, "load", lambda service: type("SlowProxySvc", (), {}))
monkeypatch.setattr(handlers, "SessionLogBuffer", RecordingBuffer)
monkeypatch.setattr(handlers, "create_service_instance", failed_check)
stub_service_build(monkeypatch, failed_check)
response = asyncio.run(handlers.session_create_handler({"service": "EXAMPLE", "title_id": "t"}))