Skip to content

Commit c2517fa

Browse files
fix(tests): add db fixture to rotation edge case tests
Tests that use mark_rate_limited now need a database initialized since the method persists rate limits to SQLite. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c1734ce commit c2517fa

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

tests/unit/rotation/test_rotation_edge_cases.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import pytest
1212

13+
from claude_code_proxy.db import init_db
1314
from claude_code_proxy.rotation.pool import AccountState, RotationPool
1415

1516

@@ -41,6 +42,14 @@ def temp_accounts_file(tmp_path: Path) -> Path:
4142
return accounts_path
4243

4344

45+
@pytest.fixture
46+
async def db_path(tmp_path: Path) -> Path:
47+
"""Initialize a temporary test database."""
48+
db_file = tmp_path / "test.db"
49+
await init_db(db_file)
50+
return db_file
51+
52+
4453
@pytest.mark.unit
4554
@pytest.mark.asyncio
4655
async def test_concurrent_account_selection(temp_accounts_file: Path) -> None:
@@ -81,7 +90,9 @@ async def test_concurrent_account_selection(temp_accounts_file: Path) -> None:
8190

8291
@pytest.mark.unit
8392
@pytest.mark.asyncio
84-
async def test_file_reload_during_active_requests(temp_accounts_file: Path) -> None:
93+
async def test_file_reload_during_active_requests(
94+
temp_accounts_file: Path, db_path: Path
95+
) -> None:
8596
"""Test that file reload preserves state during active requests.
8697
8798
Verifies:
@@ -149,7 +160,9 @@ async def test_token_refresh_during_failover(temp_accounts_file: Path) -> None:
149160

150161
@pytest.mark.unit
151162
@pytest.mark.asyncio
152-
async def test_all_accounts_rate_limited_recovery(temp_accounts_file: Path) -> None:
163+
async def test_all_accounts_rate_limited_recovery(
164+
temp_accounts_file: Path, db_path: Path
165+
) -> None:
153166
"""Test recovery when all accounts become rate limited.
154167
155168
Verifies:

0 commit comments

Comments
 (0)