mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 10:25:23 -04:00
5078f9d390
* feat: update DifyPluginEnv to set default for REMOTE_INSTALL_URL and add unit tests for environment configurations - Set default value of REMOTE_INSTALL_URL to None in DifyPluginEnv. - Introduced unit tests for various installation methods including local, remote, and serverless configurations, ensuring proper functionality without parameters and with specific settings. * fix: update condition for install_url check in Plugin class - Changed the condition to explicitly check for None instead of a truthy value, improving clarity and preventing potential issues with falsy values. * apply ruff
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from dify_plugin.config.config import DifyPluginEnv, InstallMethod
|
|
|
|
|
|
def test_launch():
|
|
"""
|
|
Env should works without any parameters and env variables
|
|
"""
|
|
env = DifyPluginEnv()
|
|
|
|
assert InstallMethod.Local == env.INSTALL_METHOD
|
|
|
|
|
|
def test_launch_local_plugin():
|
|
"""
|
|
Env should works without any parameters and env variables
|
|
"""
|
|
env = DifyPluginEnv(
|
|
INSTALL_METHOD=InstallMethod.Local,
|
|
)
|
|
|
|
assert InstallMethod.Local == env.INSTALL_METHOD
|
|
|
|
|
|
def test_launch_remote_plugin():
|
|
"""
|
|
Env should works with remote install url and key
|
|
"""
|
|
env = DifyPluginEnv(
|
|
INSTALL_METHOD=InstallMethod.Remote,
|
|
REMOTE_INSTALL_URL="debug.dify.ai:5003",
|
|
REMOTE_INSTALL_KEY="19dcf2f3-2856-4fa4-b32b-9ece9b741977",
|
|
)
|
|
|
|
assert InstallMethod.Remote == env.INSTALL_METHOD
|
|
assert env.REMOTE_INSTALL_URL == "debug.dify.ai:5003"
|
|
assert env.REMOTE_INSTALL_KEY == "19dcf2f3-2856-4fa4-b32b-9ece9b741977"
|
|
|
|
|
|
def test_launch_serverless_plugin():
|
|
"""
|
|
Env should works with serverless install method
|
|
"""
|
|
env = DifyPluginEnv(
|
|
INSTALL_METHOD=InstallMethod.Serverless,
|
|
SERVERLESS_HOST="0.0.0.0",
|
|
SERVERLESS_PORT=8080,
|
|
)
|
|
|
|
assert InstallMethod.Serverless == env.INSTALL_METHOD
|
|
assert env.SERVERLESS_HOST == "0.0.0.0"
|
|
assert env.SERVERLESS_PORT == 8080
|