33
44def test_api_url_defaults_correctly (monkeypatch ):
55 monkeypatch .setenv ("AGENTBOX_DOMAIN" , "" )
6+ monkeypatch .delenv ("AGENTBOX_REGION" , raising = False )
67
78 config = ConnectionConfig ()
8- assert config .api_url == "https://api.sandbox.ucloudai.com"
9+ assert config .api_url == "https://api.cn-wlcb. sandbox.ucloudai.com"
910
1011
1112def test_api_url_in_args ():
@@ -25,3 +26,45 @@ def test_api_url_has_correct_priority(monkeypatch):
2526
2627 config = ConnectionConfig (api_url = "http://localhost:8080" )
2728 assert config .api_url == "http://localhost:8080"
29+
30+
31+ def test_region_cn_wlcb (monkeypatch ):
32+ monkeypatch .delenv ("AGENTBOX_DOMAIN" , raising = False )
33+ monkeypatch .setenv ("AGENTBOX_REGION" , "cn-wlcb" )
34+
35+ config = ConnectionConfig ()
36+ assert config .domain == "cn-wlcb.sandbox.ucloudai.com"
37+ assert config .api_url == "https://api.cn-wlcb.sandbox.ucloudai.com"
38+
39+
40+ def test_region_us_ca (monkeypatch ):
41+ monkeypatch .delenv ("AGENTBOX_DOMAIN" , raising = False )
42+ monkeypatch .setenv ("AGENTBOX_REGION" , "us-ca" )
43+
44+ config = ConnectionConfig ()
45+ assert config .domain == "us-ca.sandbox.ucloudai.com"
46+ assert config .api_url == "https://api.us-ca.sandbox.ucloudai.com"
47+
48+
49+ def test_domain_takes_priority_over_region (monkeypatch ):
50+ monkeypatch .setenv ("AGENTBOX_DOMAIN" , "custom.example.com" )
51+ monkeypatch .setenv ("AGENTBOX_REGION" , "us-ca" )
52+
53+ config = ConnectionConfig ()
54+ assert config .domain == "custom.example.com"
55+ assert config .api_url == "https://api.custom.example.com"
56+
57+
58+ def test_domain_arg_takes_priority_over_region (monkeypatch ):
59+ monkeypatch .setenv ("AGENTBOX_REGION" , "us-ca" )
60+
61+ config = ConnectionConfig (domain = "override.example.com" )
62+ assert config .domain == "override.example.com"
63+
64+
65+ def test_default_region_is_cn_wlcb (monkeypatch ):
66+ monkeypatch .delenv ("AGENTBOX_DOMAIN" , raising = False )
67+ monkeypatch .delenv ("AGENTBOX_REGION" , raising = False )
68+
69+ config = ConnectionConfig ()
70+ assert config .domain == "cn-wlcb.sandbox.ucloudai.com"
0 commit comments