feat: add python source loader

This commit is contained in:
lda
2026-06-11 18:46:14 +07:00 Verified
parent e1ac095df2
commit c114cde2da
5 changed files with 163 additions and 1 deletions
+39
View File
@@ -0,0 +1,39 @@
from __future__ import annotations
import pytest
from wf_sources_python import load_python_source
def test_load_python_source_from_sequence_registry() -> None:
source = load_python_source(
source_id="local.ops",
module="tests.fixtures.python_source_ops",
registry="registry",
)
assert source.id == "local.ops"
assert source.kind == "python"
assert set(source.capabilities.node_specs) == {
"local.ops.echo",
"local.ops.upper",
}
assert source.permissions.safe_for_workflow is True
def test_load_python_source_rejects_missing_registry() -> None:
with pytest.raises(ValueError, match="missing registry object"):
load_python_source(
source_id="local.ops",
module="tests.fixtures.python_source_ops",
registry="missing",
)
def test_load_python_source_rejects_non_node_spec() -> None:
with pytest.raises(TypeError, match="expected NodeSpec"):
load_python_source(
source_id="local.ops",
module="math",
registry="pi",
)