Skip to content

Commit 2190793

Browse files
committed
Add ratelink.testing package initializer
Create ratelink/testing/__init__.py to centralize and re-export testing utilities. The new module exposes mock rate limiters and scripted behavior, time-machine helpers (freeze_time, advance_time, TimeMachine, MonkeyPatchedTimeMachine), assertion helpers for rate-limiter tests, pytest fixtures (for conftest.py), and load-testing/benchmarking tools (simulate_load, benchmark_algorithm, compare_algorithms, stress_test). This makes the test helpers available under ratelink.testing for easier imports in tests.
1 parent 49f83ad commit 2190793

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

ratelink/testing/__init__.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
Testing utilities for Ratelink.
3+
4+
Provides mock limiters, time control, assertion helpers, pytest fixtures,
5+
and load testing tools to make testing rate limiters easy and effective.
6+
"""
7+
8+
from .assertions import (
9+
RateLimitAssertionError,
10+
assert_allowed,
11+
assert_denied,
12+
assert_eventually_allowed,
13+
assert_limit_equals,
14+
assert_remaining,
15+
assert_retry_after,
16+
assert_state,
17+
assert_state_contains,
18+
assert_allows_n_then_denies,
19+
)
20+
from .fixtures import (
21+
frozen_time,
22+
limiter_with_time,
23+
memory_limiter,
24+
mock_limiter,
25+
mock_limiter_deny,
26+
postgres_limiter,
27+
redis_limiter,
28+
scripted_limiter,
29+
time_machine,
30+
)
31+
from .load import (
32+
LoadTestResult,
33+
benchmark_algorithm,
34+
compare_algorithms,
35+
simulate_load,
36+
simulate_load_async,
37+
stress_test,
38+
)
39+
from .mock import MockRateLimiter, ScriptedBehavior
40+
from .time_machine import MonkeyPatchedTimeMachine, TimeMachine, advance_time, freeze_time
41+
42+
__all__ = [
43+
# Mock
44+
"MockRateLimiter",
45+
"ScriptedBehavior",
46+
# Time Machine
47+
"TimeMachine",
48+
"MonkeyPatchedTimeMachine",
49+
"freeze_time",
50+
"advance_time",
51+
# Assertions
52+
"RateLimitAssertionError",
53+
"assert_allowed",
54+
"assert_denied",
55+
"assert_remaining",
56+
"assert_state",
57+
"assert_allows_n_then_denies",
58+
"assert_retry_after",
59+
"assert_limit_equals",
60+
"assert_eventually_allowed",
61+
"assert_state_contains",
62+
# Fixtures (imported in conftest.py)
63+
"mock_limiter",
64+
"mock_limiter_deny",
65+
"scripted_limiter",
66+
"time_machine",
67+
"frozen_time",
68+
"memory_limiter",
69+
"redis_limiter",
70+
"postgres_limiter",
71+
"limiter_with_time",
72+
# Load Testing
73+
"LoadTestResult",
74+
"simulate_load",
75+
"simulate_load_async",
76+
"benchmark_algorithm",
77+
"compare_algorithms",
78+
"stress_test",
79+
]

0 commit comments

Comments
 (0)