|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | from resend.exceptions import (ApplicationError, MissingApiKeyError, |
6 | | - ResendError, ValidationError, |
| 6 | + RateLimitError, ResendError, ValidationError, |
7 | 7 | raise_for_code_and_type) |
8 | 8 |
|
9 | 9 |
|
@@ -32,3 +32,24 @@ def test_error_500(self) -> None: |
32 | 32 | with pytest.raises(ApplicationError) as e: |
33 | 33 | raise_for_code_and_type(500, "application_error", "err") |
34 | 34 | assert e.type is ApplicationError |
| 35 | + |
| 36 | + def test_rate_limit_exceeded_error(self) -> None: |
| 37 | + with pytest.raises(RateLimitError) as e: |
| 38 | + raise_for_code_and_type(429, "rate_limit_exceeded", "Rate limit exceeded") |
| 39 | + assert e.type is RateLimitError |
| 40 | + assert e.value.code == 429 |
| 41 | + assert e.value.error_type == "rate_limit_exceeded" |
| 42 | + |
| 43 | + def test_daily_quota_exceeded_error(self) -> None: |
| 44 | + with pytest.raises(RateLimitError) as e: |
| 45 | + raise_for_code_and_type(429, "daily_quota_exceeded", "Daily quota exceeded") |
| 46 | + assert e.type is RateLimitError |
| 47 | + assert e.value.code == 429 |
| 48 | + assert e.value.error_type == "daily_quota_exceeded" |
| 49 | + |
| 50 | + def test_monthly_quota_exceeded_error(self) -> None: |
| 51 | + with pytest.raises(RateLimitError) as e: |
| 52 | + raise_for_code_and_type(429, "monthly_quota_exceeded", "Monthly quota exceeded") |
| 53 | + assert e.type is RateLimitError |
| 54 | + assert e.value.code == 429 |
| 55 | + assert e.value.error_type == "monthly_quota_exceeded" |
0 commit comments