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 -3
View File
@@ -2,9 +2,11 @@
import base64
import zlib
from types import SimpleNamespace
import pytest
from tests.remote.sessions import launch_session
from unshackle.core.api import handlers, key_policy
from unshackle.core.api.errors import APIError
from unshackle.core.api.handlers import load_client_cookies
@@ -52,12 +54,12 @@ def test_load_client_cookies_rejects_a_malformed_blob(blob):
@pytest.fixture
def built_ctx(monkeypatch):
"""Stub the service machinery so create_service_instance runs without a real service; return the captured ctx."""
"""Stub the service machinery so a session launch runs without a real service; return the captured ctx."""
seen = {}
def fake_instantiate(parent_ctx, *args):
seen["ctx"] = parent_ctx
return object()
return SimpleNamespace()
monkeypatch.setattr(key_policy, "load_service_config", lambda service: {})
monkeypatch.setattr(handlers, "load_full_cdm", lambda *args: None)
@@ -65,7 +67,7 @@ def built_ctx(monkeypatch):
monkeypatch.setattr(handlers, "instantiate_service", fake_instantiate)
def build(data):
_, cookies, _ = handlers.create_service_instance("EXAMPLE", "title", data, None, [], None)
cookies = launch_session("EXAMPLE", "title", data).cookies
return seen["ctx"], cookies
return build