Files
Van/攻城狮鹿鸣君 92a1b50f91 isolate providers before expanding MediaHub integrations
Replace provider-switching task nodes with provider-specific config nodes and stable generic image/video execution contracts. Add Agnes Image 2.1 and Video 2.0 using behavior verified against the live API.

Constraint: Old workflows are intentionally unsupported; Agnes Image 2.0 remains documentation-only.

Rejected: Single task nodes with provider dropdowns | provider-specific union schemas create serialization risk and cross-provider coupling.

Confidence: high

Scope-risk: broad

Directive: New providers must register isolated operation adapters and reuse generic execution nodes without modifying existing provider packages.

Tested: 120 pytest tests; Python compileall; JavaScript syntax; 16 workflow JSON validations; restarted ComfyUI smoke; live Agnes Image 2.1 T2I/I2I; live Agnes Video 2.0 T2V completion and I2V Data URI submission.

Not-tested: User-driven visual inspection of every imported UI workflow and full completed Agnes I2V download.
2026-06-13 17:49:31 +08:00

26 lines
845 B
Python

import pytest
from mediahub.core.contracts import MediaJob, MediaRequest
from mediahub.core.registry import ProviderRegistry
def test_media_contracts_never_serialize_api_keys():
request = MediaRequest("Agnes", "image.generate", {"prompt": "cat"})
job = MediaJob("Agnes", "video.resolve", "task-1", {"video_id": "video-1"})
assert "api_key" not in request.to_dict()
assert "api_key" not in job.to_dict()
def test_registry_dispatches_by_provider_and_operation():
registry = ProviderRegistry()
registry.register("Agnes", "image.generate", lambda **kwargs: kwargs["value"])
assert registry.call("Agnes", "image.generate", value=42) == 42
def test_registry_reports_missing_adapter():
with pytest.raises(ValueError, match="No adapter registered"):
ProviderRegistry().call("Missing", "image.generate")