Skip to content

Commit 5078f9d

Browse files
authored
fix: update DifyPluginEnv to set default for REMOTE_INSTALL_URL (#142)
* 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
1 parent 371bbbf commit 5078f9d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

python/tests/config/test_config.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from dify_plugin.config.config import DifyPluginEnv, InstallMethod
2+
3+
4+
def test_launch():
5+
"""
6+
Env should works without any parameters and env variables
7+
"""
8+
env = DifyPluginEnv()
9+
10+
assert InstallMethod.Local == env.INSTALL_METHOD
11+
12+
13+
def test_launch_local_plugin():
14+
"""
15+
Env should works without any parameters and env variables
16+
"""
17+
env = DifyPluginEnv(
18+
INSTALL_METHOD=InstallMethod.Local,
19+
)
20+
21+
assert InstallMethod.Local == env.INSTALL_METHOD
22+
23+
24+
def test_launch_remote_plugin():
25+
"""
26+
Env should works with remote install url and key
27+
"""
28+
env = DifyPluginEnv(
29+
INSTALL_METHOD=InstallMethod.Remote,
30+
REMOTE_INSTALL_URL="debug.dify.ai:5003",
31+
REMOTE_INSTALL_KEY="19dcf2f3-2856-4fa4-b32b-9ece9b741977",
32+
)
33+
34+
assert InstallMethod.Remote == env.INSTALL_METHOD
35+
assert env.REMOTE_INSTALL_URL == "debug.dify.ai:5003"
36+
assert env.REMOTE_INSTALL_KEY == "19dcf2f3-2856-4fa4-b32b-9ece9b741977"
37+
38+
39+
def test_launch_serverless_plugin():
40+
"""
41+
Env should works with serverless install method
42+
"""
43+
env = DifyPluginEnv(
44+
INSTALL_METHOD=InstallMethod.Serverless,
45+
SERVERLESS_HOST="0.0.0.0",
46+
SERVERLESS_PORT=8080,
47+
)
48+
49+
assert InstallMethod.Serverless == env.INSTALL_METHOD
50+
assert env.SERVERLESS_HOST == "0.0.0.0"
51+
assert env.SERVERLESS_PORT == 8080

0 commit comments

Comments
 (0)