Test getting usage limits.
(mock_get)
| 369 | |
| 370 | @patch('simstudio.requests.Session.get') |
| 371 | def 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') |
nothing calls this directly
no test coverage detected