mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-30 13:05:08 +00:00
refactor(api): build list, search and session services through one launch_served
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user