Files
dify-plugin-sdks/python/tests/interfaces/trigger/test_construct_trigger.py
T
Yeuoly e8d4949f0b refactor: simplify trigger implementation in tests
- Removed the TriggerRuntime dependency from the test_construct_trigger.py file, streamlining the trigger instantiation process.
- Adjusted imports to reflect the updated structure, enhancing code clarity.

These changes contribute to a cleaner and more maintainable test setup for the trigger functionality.
2025-09-26 23:25:43 +08:00

35 lines
1.0 KiB
Python

from collections.abc import Mapping
from concurrent.futures import ThreadPoolExecutor
from werkzeug import Request
from dify_plugin.core.runtime import Session
from dify_plugin.core.server.stdio.request_reader import StdioRequestReader
from dify_plugin.core.server.stdio.response_writer import StdioResponseWriter
from dify_plugin.entities.trigger import Event
from dify_plugin.interfaces.trigger import TriggerEvent
def test_construct_trigger():
"""
Test the constructor of Trigger
NOTE:
- This test is to ensure that the constructor of Trigger is not overridden.
- And ensure a breaking change will be detected by CI.
"""
class TriggerImpl(TriggerEvent):
def _trigger(self, request: Request, parameters: Mapping) -> Event:
return Event(variables={})
session = Session(
session_id="test",
executor=ThreadPoolExecutor(max_workers=1),
reader=StdioRequestReader(),
writer=StdioResponseWriter(),
)
trigger = TriggerImpl(session=session)
assert trigger is not None