testsAndMisc/PYTHON/lichess_bot/tests/test_utils.py
Krzysztof kuhy Rudnicki 3ac56e541e Enable D100-D107 docstring rules: add docstrings to all modules, classes, methods, and functions
- Added module docstrings to 19 Python files
- Added class docstrings to 5 classes (ScreenLocker, PokerModifierApp, etc.)
- Added method docstrings to 22 methods
- Added function docstrings to 25 functions
- Added __init__ docstrings to 5 classes
- Removed D100-D107 from ruff ignore list (docstrings now enforced)
- Removed deprecated ANN101, ANN102, UP038 rules from ignore list
- Fixed UP038: use union types in isinstance() calls
- All ruff checks now pass with full docstring enforcement
2025-11-30 14:45:55 +01:00

25 lines
629 B
Python

"""Tests for utility functions."""
from PYTHON.lichess_bot.utils import backoff_sleep
def test_backoff_sleep_increments_and_caps(monkeypatch):
"""Test that backoff sleep increments and respects the cap."""
slept = []
def fake_sleep(sec):
slept.append(sec)
monkeypatch.setattr("time.sleep", fake_sleep)
b = 0
b = backoff_sleep(b, base=0.1, cap=0.3)
b = backoff_sleep(b, base=0.1, cap=0.3)
b = backoff_sleep(b, base=0.1, cap=0.3)
assert b >= 1
assert len(slept) == 3
# 0.1, 0.2, 0.3 (capped)
assert slept[0] == 0.1
assert slept[1] == 0.2
assert slept[2] == 0.3