test: add full test suite with 100% coverage across all modules
All checks were successful
CI / Lint (push) Successful in 6s
CI / Test (push) Successful in 7s
CI / Build & Push (push) Successful in 15s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-29 13:17:20 -04:00
parent dd5ac945bd
commit def491a4d4
6 changed files with 516 additions and 0 deletions

41
tests/test_scheduler.py Normal file
View File

@@ -0,0 +1,41 @@
import pytest
from app.scheduler import start_scheduler
class TestStartScheduler:
def test_registers_standings_refresh_every_600_seconds(self, mocker):
mock_schedule = mocker.patch("app.scheduler.schedule")
mocker.patch("app.scheduler.time.sleep", side_effect=StopIteration)
with pytest.raises(StopIteration):
start_scheduler()
intervals = [call[0][0] for call in mock_schedule.every.call_args_list]
assert 600 in intervals
def test_registers_score_refresh_every_10_seconds(self, mocker):
mock_schedule = mocker.patch("app.scheduler.schedule")
mocker.patch("app.scheduler.time.sleep", side_effect=StopIteration)
with pytest.raises(StopIteration):
start_scheduler()
intervals = [call[0][0] for call in mock_schedule.every.call_args_list]
assert 10 in intervals
def test_runs_pending_on_each_tick(self, mocker):
mock_schedule = mocker.patch("app.scheduler.schedule")
call_count = {"n": 0}
def sleep_twice(_):
call_count["n"] += 1
if call_count["n"] >= 2:
raise StopIteration
mocker.patch("app.scheduler.time.sleep", side_effect=sleep_twice)
with pytest.raises(StopIteration):
start_scheduler()
assert mock_schedule.run_pending.call_count >= 2