Skip to content

Commit 7b41bc9

Browse files
test: add protocol conformance pins for runtime implementations (#1811)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 9e44d4b commit 7b41bc9

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""Protocol conformance for uipath-runtime protocol implementations.
2+
3+
Every protocol-annotated assignment below is a typed boundary: mypy verifies
4+
the implementation against the protocol surface of the installed
5+
uipath-runtime version. A dependency bump that adds or changes protocol
6+
members fails typecheck on these lines until the implementations catch up.
7+
8+
Deliberately construction-only: no runtime behavior is exercised here.
9+
"""
10+
11+
import uuid
12+
13+
from uipath.core.events import EventBus
14+
from uipath.core.tracing import UiPathTraceManager
15+
from uipath.eval.runtime import UiPathEvalContext, UiPathEvalRuntime
16+
from uipath.functions import (
17+
UiPathDebugFunctionsRuntime,
18+
UiPathFunctionsRuntime,
19+
UiPathFunctionsRuntimeFactory,
20+
)
21+
from uipath.platform.resume_triggers import (
22+
UiPathResumeTriggerCreator,
23+
UiPathResumeTriggerReader,
24+
)
25+
from uipath.runtime import (
26+
UiPathRuntimeFactoryProtocol,
27+
UiPathRuntimeProtocol,
28+
)
29+
from uipath.runtime.resumable.protocols import (
30+
UiPathResumeTriggerCreatorProtocol,
31+
UiPathResumeTriggerReaderProtocol,
32+
)
33+
34+
35+
def test_functions_runtime_satisfies_runtime_protocol() -> None:
36+
runtime: UiPathRuntimeProtocol = UiPathFunctionsRuntime(
37+
file_path="main.py",
38+
function_name="main",
39+
entrypoint_name="main",
40+
)
41+
42+
# the debug wrapper's `delegate` parameter is protocol-typed: passing the
43+
# real functions runtime through it is a second typed boundary, and the
44+
# wrapper itself must satisfy the protocol too
45+
debug_runtime: UiPathRuntimeProtocol = UiPathDebugFunctionsRuntime(
46+
delegate=runtime,
47+
entrypoint_path="main.py",
48+
function_name="main",
49+
)
50+
51+
assert debug_runtime is not None
52+
53+
54+
def test_functions_factory_satisfies_factory_protocol() -> None:
55+
factory: UiPathRuntimeFactoryProtocol = UiPathFunctionsRuntimeFactory()
56+
57+
# the eval runtime's `factory` parameter is protocol-typed: the real
58+
# functions factory flows through it. UiPathEvalRuntime itself is a
59+
# specialized runtime (no stream, argument-less execute) and is
60+
# deliberately NOT pinned against UiPathRuntimeProtocol.
61+
context = UiPathEvalContext()
62+
context.execution_id = str(uuid.uuid4())
63+
eval_runtime = UiPathEvalRuntime(
64+
context=context,
65+
factory=factory,
66+
trace_manager=UiPathTraceManager(),
67+
event_bus=EventBus(),
68+
)
69+
70+
assert eval_runtime is not None
71+
72+
73+
def test_standalone_trigger_classes_satisfy_protocols() -> None:
74+
# cover direct consumers of the standalone creator/reader classes
75+
creator: UiPathResumeTriggerCreatorProtocol = UiPathResumeTriggerCreator()
76+
reader: UiPathResumeTriggerReaderProtocol = UiPathResumeTriggerReader()
77+
78+
assert creator is not None
79+
assert reader is not None

0 commit comments

Comments
 (0)