Files
ecm_sync_system/tests/unit/test_registry_unified_handler_lookup.py
T
2026-03-19 11:44:02 +08:00

50 lines
1.4 KiB
Python

from __future__ import annotations
from pydantic import BaseModel
from sync_state_machine.common.registry import DomainRegistry
class RegistryLookupSchema(BaseModel):
__test__ = False
id: str
class RegistryLookupNode:
__test__ = False
class RegistryLookupJsonlHandler:
__test__ = False
class RegistryLookupApiHandler:
__test__ = False
class RegistryLookupCustomHandler:
__test__ = False
def test_registry_supports_unified_handler_lookup() -> None:
node_type = "registry_lookup_demo"
if DomainRegistry.is_registered(node_type):
reg = DomainRegistry.get_registration(node_type)
reg.jsonl_handler_class = RegistryLookupJsonlHandler
reg.api_handler_class = RegistryLookupApiHandler
reg.handler_classes["custom"] = RegistryLookupCustomHandler
else:
DomainRegistry.register(
node_type=node_type,
schema=RegistryLookupSchema,
node_class=RegistryLookupNode,
jsonl_handler_class=RegistryLookupJsonlHandler,
api_handler_class=RegistryLookupApiHandler,
)
DomainRegistry.register_handler(node_type, "custom", RegistryLookupCustomHandler)
assert DomainRegistry.get_handler(node_type, "jsonl") is RegistryLookupJsonlHandler
assert DomainRegistry.get_handler(node_type, "api") is RegistryLookupApiHandler
assert DomainRegistry.get_handler(node_type, "custom") is RegistryLookupCustomHandler