MCPcopy Create free account
hub / github.com/Open-Bee/DataStudio / TestBaseAPIEdgeCases

Class TestBaseAPIEdgeCases

tests/models/test_base_api.py:251–291  ·  view source on GitHub ↗

Edge case tests for BaseAPI.

Source from the content-addressed store, hash-verified

249
250
251class TestBaseAPIEdgeCases:
252 """Edge case tests for BaseAPI."""
253
254 def test_generate_with_none_message(self, api):
255 """Test generating with None in messages."""
256 # This might raise or handle gracefully depending on implementation
257 try:
258 results = api.generate([None])
259 except (TypeError, AssertionError):
260 pass # Expected
261
262 def test_generate_with_empty_content(self, api):
263 """Test generating with empty content."""
264 results = api.generate([""])
265 assert isinstance(results, list)
266
267 def test_retry_on_failure(self):
268 """Test retry logic on failure."""
269 from datastudio.models.base import BaseAPI
270
271 class FailingAPI(BaseAPI):
272 def __init__(self):
273 super().__init__(retry=2, wait=0.01)
274 self.call_count = 0
275
276 def generate_inner(self, inputs, **kwargs):
277 self.call_count += 1
278 if self.call_count < 2:
279 return 1, None, None # Failure
280 return 0, "success", None
281
282 api = FailingAPI()
283 result = api.process_single_message("test", {})
284 assert result == "success"
285 assert api.call_count == 2
286
287 def test_concurrent_generation(self, api):
288 """Test concurrent generation."""
289 messages = ["msg1", "msg2", "msg3", "msg4"]
290 results = api.generate(messages)
291 assert len(results) == 4
292
293
294class TestBaseAPIAbstract:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected