Skip to content

Commit 387e0d2

Browse files
committed
do not allow overriding intersect_sdk_listen_for_service_event in base capability class
Signed-off-by: Lance Drane <[email protected]>
1 parent cbe7f7c commit 387e0d2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/intersect_sdk/capability/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def __init_subclass__(cls) -> None:
6868
is not IntersectBaseCapabilityImplementation.intersect_sdk_emit_event
6969
or cls.intersect_sdk_call_service
7070
is not IntersectBaseCapabilityImplementation.intersect_sdk_call_service
71+
or cls.intersect_sdk_listen_for_service_event
72+
is not IntersectBaseCapabilityImplementation.intersect_sdk_listen_for_service_event
7173
):
7274
msg = f"{cls.__name__}: Attempted to override a reserved INTERSECT-SDK function (don't start your function names with '_intersect_sdk_' or 'intersect_sdk_')"
7375
raise RuntimeError(msg)

tests/unit/test_base_capability_implementation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ def intersect_sdk_call_service(
7373

7474
assert 'BadClass3: Attempted to override a reserved INTERSECT-SDK function' in str(ex)
7575

76+
with pytest.raises(RuntimeError) as ex:
77+
78+
class BadClass4(IntersectBaseCapabilityImplementation):
79+
def intersect_sdk_listen_for_service_event(
80+
self,
81+
service,
82+
event_name,
83+
response_handler,
84+
) -> None:
85+
pass
86+
87+
assert 'BadClass4: Attempted to override a reserved INTERSECT-SDK function' in str(ex)
88+
7689

7790
# Note that the ONLY thing the capability itself checks for are annotated functions.
7891
# The event definitions and overall schema validation are a service-specific feature

0 commit comments

Comments
 (0)