@@ -70,29 +70,46 @@ def check_headers(**kwargs):
70
70
@pytest .mark .parametrize (
71
71
"OSPARC_API_HOST" , ["https://api.foo.com" , "https://api.bar.com/" , None ]
72
72
)
73
+ @pytest .mark .parametrize (
74
+ "OSPARC_API_BASE_URL" , ["https://api.sdkjbf.com" , "https://api.alskjd.com/" , None ]
75
+ )
73
76
@pytest .mark .parametrize ("OSPARC_API_KEY" , ["key" , None ])
74
77
@pytest .mark .parametrize ("OSPARC_API_SECRET" , ["secret" , None ])
75
78
def test_api_client_constructor (
76
79
monkeypatch : pytest .MonkeyPatch ,
77
80
OSPARC_API_HOST : Optional [str ],
81
+ OSPARC_API_BASE_URL : Optional [str ],
78
82
OSPARC_API_KEY : Optional [str ],
79
83
OSPARC_API_SECRET : Optional [str ],
80
84
):
81
85
with monkeypatch .context () as patch :
82
86
patch .delenv ("OSPARC_API_HOST" , raising = False )
87
+ patch .delenv ("OSPARC_API_BASE_URL" , raising = False )
83
88
patch .delenv ("OSPARC_API_KEY" , raising = False )
84
89
patch .delenv ("OSPARC_API_SECRET" , raising = False )
85
90
86
91
if OSPARC_API_HOST is not None :
87
92
patch .setenv ("OSPARC_API_HOST" , OSPARC_API_HOST )
93
+ if OSPARC_API_BASE_URL is not None :
94
+ patch .setenv ("OSPARC_API_BASE_URL" , OSPARC_API_BASE_URL )
88
95
if OSPARC_API_KEY is not None :
89
96
patch .setenv ("OSPARC_API_KEY" , OSPARC_API_KEY )
90
97
if OSPARC_API_SECRET is not None :
91
98
patch .setenv ("OSPARC_API_SECRET" , OSPARC_API_SECRET )
92
99
93
- if OSPARC_API_HOST and OSPARC_API_KEY and OSPARC_API_SECRET :
100
+ if (
101
+ (OSPARC_API_HOST or OSPARC_API_BASE_URL )
102
+ and OSPARC_API_KEY
103
+ and OSPARC_API_SECRET
104
+ ):
94
105
api = ApiClient ()
95
- assert api .configuration .host == OSPARC_API_HOST .rstrip ("/" )
106
+ # if OSPARC_API_BASE_URL and OSPARC_API_HOST are both
107
+ # in env, the former has preference
108
+ if OSPARC_API_BASE_URL is not None :
109
+ assert api .configuration .host == OSPARC_API_BASE_URL .rstrip ("/" )
110
+ elif OSPARC_API_HOST is not None :
111
+ assert api .configuration .host == OSPARC_API_HOST .rstrip ("/" )
112
+
96
113
assert api .configuration .username == OSPARC_API_KEY
97
114
assert api .configuration .password == OSPARC_API_SECRET
98
115
0 commit comments