MCPcopy Index your code
hub / github.com/simstudioai/sim / test_get_usage_limits_success

Function test_get_usage_limits_success

packages/python-sdk/tests/test_client.py:371–409  ·  view source on GitHub ↗

Test getting usage limits.

(mock_get)

Source from the content-addressed store, hash-verified

369
370@patch('simstudio.requests.Session.get')
371def test_get_usage_limits_success(mock_get):
372 """Test getting usage limits."""
373 mock_response = Mock()
374 mock_response.ok = True
375 mock_response.json.return_value = {
376 "success": True,
377 "rateLimit": {
378 "sync": {
379 "isLimited": False,
380 "limit": 100,
381 "remaining": 95,
382 "resetAt": "2024-01-01T01:00:00Z"
383 },
384 "async": {
385 "isLimited": False,
386 "limit": 50,
387 "remaining": 48,
388 "resetAt": "2024-01-01T01:00:00Z"
389 },
390 "authType": "api"
391 },
392 "usage": {
393 "currentPeriodCost": 1.23,
394 "limit": 100.0,
395 "plan": "pro"
396 }
397 }
398 mock_response.headers.get.return_value = None
399 mock_get.return_value = mock_response
400
401 client = SimStudioClient(api_key="test-api-key", base_url="https://test.sim.ai")
402 result = client.get_usage_limits()
403
404 assert result.success is True
405 assert result.rate_limit["sync"]["limit"] == 100
406 assert result.rate_limit["async"]["limit"] == 50
407 assert result.usage["currentPeriodCost"] == 1.23
408 assert result.usage["plan"] == "pro"
409 mock_get.assert_called_once_with("https://test.sim.ai/api/users/me/usage-limits")
410
411
412@patch('simstudio.requests.Session.get')

Callers

nothing calls this directly

Calls 2

get_usage_limitsMethod · 0.95
SimStudioClientClass · 0.90

Tested by

no test coverage detected