Skip to content

Commit ba8a735

Browse files
committed
Fix unit tests
1 parent f2529a4 commit ba8a735

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

unit_tests/sources/declarative/parsers/test_model_to_component_factory.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,12 +3633,12 @@ def test_api_budget():
36333633
)
36343634

36353635
assert http_requester.api_budget is not None
3636-
assert http_requester.api_budget.ratelimit_reset_header == "X-RateLimit-Reset"
3637-
assert http_requester.api_budget.status_codes_for_ratelimit_hit == [429, 503]
3638-
assert len(http_requester.api_budget.policies) == 1
3636+
assert http_requester.api_budget._ratelimit_reset_header == "X-RateLimit-Reset"
3637+
assert http_requester.api_budget._status_codes_for_ratelimit_hit == [429, 503]
3638+
assert len(http_requester.api_budget._policies) == 1
36393639

36403640
# The single policy is a MovingWindowCallRatePolicy
3641-
policy = http_requester.api_budget.policies[0]
3641+
policy = http_requester.api_budget._policies[0]
36423642
assert isinstance(policy, MovingWindowCallRatePolicy)
36433643
assert policy._bucket.rates[0].limit == 3
36443644
# The 0.1s from 'PT0.1S' is stored in ms by PyRateLimiter internally
@@ -3651,12 +3651,10 @@ def test_api_budget_fixed_window_policy():
36513651
"type": "DeclarativeSource",
36523652
# Root-level api_budget referencing a FixedWindowCallRatePolicy
36533653
"api_budget": {
3654-
"type": "APIBudget",
3655-
"maximum_attempts_to_acquire": 9999,
3654+
"type": "HTTPAPIBudget",
36563655
"policies": [
36573656
{
36583657
"type": "FixedWindowCallRatePolicy",
3659-
"next_reset_ts": "2025-01-01T00:00:00Z",
36603658
"period": "PT1M", # 1 minute
36613659
"call_limit": 10,
36623660
"matchers": [
@@ -3701,20 +3699,16 @@ def test_api_budget_fixed_window_policy():
37013699
)
37023700

37033701
assert http_requester.api_budget is not None
3704-
assert http_requester.api_budget.maximum_attempts_to_acquire == 9999
3705-
assert len(http_requester.api_budget.policies) == 1
3702+
assert len(http_requester.api_budget._policies) == 1
37063703

37073704
from airbyte_cdk.sources.streams.call_rate import FixedWindowCallRatePolicy
37083705

3709-
policy = http_requester.api_budget.policies[0]
3706+
policy = http_requester.api_budget._policies[0]
37103707
assert isinstance(policy, FixedWindowCallRatePolicy)
37113708
assert policy._call_limit == 10
37123709
# The period is "PT1M" => 60 seconds
37133710
assert policy._offset.total_seconds() == 60
37143711

3715-
expected_reset_dt = datetime(2025, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
3716-
assert policy._next_reset_ts == expected_reset_dt
3717-
37183712
assert len(policy._matchers) == 1
37193713
matcher = policy._matchers[0]
37203714
from airbyte_cdk.sources.streams.call_rate import HttpRequestRegexMatcher

0 commit comments

Comments
 (0)