Files
dify-plugin-sdks/python/tests/interfaces/trigger/test_construct_trigger.py
T
Harry e9df3cbd4a feat(trigger): enhance trigger execution and response handling
- Introduced new response entities for trigger operations: TriggerInvokeResponse, TriggerDispatchResponse, TriggerSubscriptionResponse, TriggerUnsubscribeResponse, and TriggerRefreshResponse.
- Updated PluginExecutor methods to utilize the new response structures, improving clarity and consistency in trigger handling.
- Enhanced HTTP request parsing and response conversion utilities for better integration with various content types.
- Refactored GitHub provider to align with the updated trigger dispatch and subscription handling mechanisms.
2025-08-30 19:36:24 +08:00

35 lines
1.1 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, TriggerRuntime
from dify_plugin.interfaces.trigger import Trigger
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(Trigger):
def _trigger(self, request: Request, parameters: Mapping) -> Event:
return Event(properties={})
session = Session(
session_id="test",
executor=ThreadPoolExecutor(max_workers=1),
reader=StdioRequestReader(),
writer=StdioResponseWriter(),
)
trigger = TriggerImpl(runtime=TriggerRuntime(credentials={}, session_id="test"), session=session)
assert trigger is not None