mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 10:25:23 -04:00
a9b6abf9fc
- Renamed classes and methods related to triggers to use "Event" terminology for consistency and clarity. - Updated the PluginExecutor, PluginRegistration, and TriggerFactory to reflect the new event handling structure. - Adjusted YAML configurations and example implementations to align with the new event definitions. - Enhanced the .gitignore file to include .DS_Store and ensure cleaner project management. These changes improve the overall coherence of the codebase and enhance the clarity of event-driven functionality.
35 lines
1.0 KiB
Python
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 Variables
|
|
from dify_plugin.interfaces.trigger import Event
|
|
|
|
|
|
def test_construct_trigger():
|
|
"""
|
|
Test the constructor of Event
|
|
|
|
NOTE:
|
|
- This test is to ensure that the constructor of Event is not overridden.
|
|
- And ensure a breaking change will be detected by CI.
|
|
"""
|
|
|
|
class TriggerImpl(Event):
|
|
def _on_event(self, request: Request, parameters: Mapping) -> Variables:
|
|
return Variables(variables={})
|
|
|
|
session = Session(
|
|
session_id="test",
|
|
executor=ThreadPoolExecutor(max_workers=1),
|
|
reader=StdioRequestReader(),
|
|
writer=StdioResponseWriter(),
|
|
)
|
|
|
|
trigger = TriggerImpl(session=session)
|
|
assert trigger is not None
|