Skip to content

Commit f064a8d

Browse files
committed
test: skip OpenAI rate-limited integration runs
1 parent 27cbd8c commit f064a8d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/tests/OpenAI.IntegrationTests/QuotaAwareTestMethodAttribute.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ public override async Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
1919
{
2020
if (result.Outcome != UnitTestOutcome.Failed ||
2121
result.TestFailureException is not { } exception ||
22-
!IsOpenAiQuotaIssue(exception))
22+
!IsOpenAiAvailabilityIssue(exception))
2323
{
2424
continue;
2525
}
2626

2727
result.Outcome = UnitTestOutcome.Inconclusive;
2828
result.TestFailureException = new AssertInconclusiveException(
29-
"OpenAI account quota or billing limit is unavailable for this live integration test.",
29+
"OpenAI account quota, billing, or rate-limit availability blocked this live integration test.",
3030
exception);
3131
}
3232

3333
return results;
3434
}
3535

36-
private static bool IsOpenAiQuotaIssue(Exception exception)
36+
private static bool IsOpenAiAvailabilityIssue(Exception exception)
3737
{
3838
foreach (var current in Flatten(exception))
3939
{
@@ -43,7 +43,8 @@ private static bool IsOpenAiQuotaIssue(Exception exception)
4343
}
4444

4545
var responseText = apiException.ResponseBody ?? apiException.Message;
46-
if (responseText.Contains("insufficient_quota", StringComparison.OrdinalIgnoreCase) ||
46+
if (apiException.StatusCode == System.Net.HttpStatusCode.TooManyRequests ||
47+
responseText.Contains("insufficient_quota", StringComparison.OrdinalIgnoreCase) ||
4748
responseText.Contains("billing_hard_limit_reached", StringComparison.OrdinalIgnoreCase) ||
4849
responseText.Contains("billing hard limit", StringComparison.OrdinalIgnoreCase))
4950
{

0 commit comments

Comments
 (0)