@@ -119,6 +119,9 @@ def mock_send(request):
119
119
mock_send_wrapper .assert_called_once ()
120
120
121
121
122
+ class ExperimentalFeatureWarning (Warning ): ...
123
+
124
+
122
125
class TestGetApiToken :
123
126
"""Test cases for _get_api_token_from_environment function covering all import paths."""
124
127
@@ -142,6 +145,7 @@ def test_cog_import_error_falls_back_to_env(self):
142
145
def test_cog_no_current_scope_method_falls_back_to_env (self ):
143
146
"""Test fallback when cog exists but has no current_scope method."""
144
147
mock_cog = mock .MagicMock ()
148
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
145
149
del mock_cog .current_scope # Remove the method
146
150
147
151
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -152,6 +156,7 @@ def test_cog_no_current_scope_method_falls_back_to_env(self):
152
156
def test_cog_current_scope_returns_none_falls_back_to_env (self ):
153
157
"""Test fallback when current_scope() returns None."""
154
158
mock_cog = mock .MagicMock ()
159
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
155
160
mock_cog .current_scope .return_value = None
156
161
157
162
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -165,6 +170,7 @@ def test_cog_scope_no_context_attr_falls_back_to_env(self):
165
170
del mock_scope .context # Remove the context attribute
166
171
167
172
mock_cog = mock .MagicMock ()
173
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
168
174
mock_cog .current_scope .return_value = mock_scope
169
175
170
176
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -178,6 +184,7 @@ def test_cog_scope_context_not_dict_falls_back_to_env(self):
178
184
mock_scope .context = "not a dict"
179
185
180
186
mock_cog = mock .MagicMock ()
187
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
181
188
mock_cog .current_scope .return_value = mock_scope
182
189
183
190
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -191,6 +198,7 @@ def test_cog_scope_no_replicate_api_token_key_falls_back_to_env(self):
191
198
mock_scope .context = {"other_key" : "other_value" } # Missing replicate_api_token
192
199
193
200
mock_cog = mock .MagicMock ()
201
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
194
202
mock_cog .current_scope .return_value = mock_scope
195
203
196
204
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -204,6 +212,7 @@ def test_cog_scope_replicate_api_token_valid_string(self):
204
212
mock_scope .context = {"REPLICATE_API_TOKEN" : "cog-token" }
205
213
206
214
mock_cog = mock .MagicMock ()
215
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
207
216
mock_cog .current_scope .return_value = mock_scope
208
217
209
218
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -217,6 +226,7 @@ def test_cog_scope_replicate_api_token_case_insensitive(self):
217
226
mock_scope .context = {"replicate_api_token" : "cog-token" }
218
227
219
228
mock_cog = mock .MagicMock ()
229
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
220
230
mock_cog .current_scope .return_value = mock_scope
221
231
222
232
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -230,6 +240,7 @@ def test_cog_scope_replicate_api_token_empty_string(self):
230
240
mock_scope .context = {"replicate_api_token" : "" } # Empty string
231
241
232
242
mock_cog = mock .MagicMock ()
243
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
233
244
mock_cog .current_scope .return_value = mock_scope
234
245
235
246
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -243,6 +254,7 @@ def test_cog_scope_replicate_api_token_none(self):
243
254
mock_scope .context = {"replicate_api_token" : None }
244
255
245
256
mock_cog = mock .MagicMock ()
257
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
246
258
mock_cog .current_scope .return_value = mock_scope
247
259
248
260
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
@@ -253,6 +265,7 @@ def test_cog_scope_replicate_api_token_none(self):
253
265
def test_cog_current_scope_raises_exception_falls_back_to_env (self ):
254
266
"""Test fallback when current_scope() raises an exception."""
255
267
mock_cog = mock .MagicMock ()
268
+ mock_cog .ExperimentalFeatureWarning = ExperimentalFeatureWarning
256
269
mock_cog .current_scope .side_effect = RuntimeError ("Scope error" )
257
270
258
271
with mock .patch .dict (os .environ , {"REPLICATE_API_TOKEN" : "env-token" }):
0 commit comments