mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-07-04 15:23:05 +02:00
- Add comprehensive tests for all packages (3572 tests, 100% branch coverage) - Split oversized test files to stay under 500-line limit - Add per-file ruff ignores for test-appropriate suppressions - Fix _cache_decks.py to properly convert JSON lists to tuples - Add session-scoped conftest fixture for logging handler cleanup (Python 3.14) - Update ruff pre-commit hook to v0.15.2 - Add codespell ignore words for test data - Add generated output files to .gitignore
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Tests for hltb module - part 3 (fetch_hltb_times)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from python_pkg.steam_backlog_enforcer.hltb import (
|
|
HLTBResult,
|
|
fetch_hltb_times,
|
|
)
|
|
|
|
|
|
class TestFetchHltbTimes:
|
|
"""Tests for fetch_hltb_times."""
|
|
|
|
def test_empty(self) -> None:
|
|
assert fetch_hltb_times([]) == []
|
|
|
|
def test_calls_batch(self) -> None:
|
|
mock_result = HLTBResult(
|
|
app_id=440, game_name="TF2", completionist_hours=50.0, similarity=1.0
|
|
)
|
|
with patch(
|
|
"python_pkg.steam_backlog_enforcer.hltb._fetch_batch",
|
|
return_value=[mock_result],
|
|
):
|
|
results = fetch_hltb_times([(440, "TF2")])
|
|
assert len(results) == 1
|
|
|
|
def test_none_cache(self) -> None:
|
|
with patch(
|
|
"python_pkg.steam_backlog_enforcer.hltb._fetch_batch",
|
|
return_value=[],
|
|
):
|
|
results = fetch_hltb_times([(440, "TF2")])
|
|
assert results == []
|
|
|
|
def test_explicit_cache(self) -> None:
|
|
with patch(
|
|
"python_pkg.steam_backlog_enforcer.hltb._fetch_batch",
|
|
return_value=[],
|
|
):
|
|
cache: dict[int, float] = {440: 10.0}
|
|
results = fetch_hltb_times([(440, "TF2")], cache=cache)
|
|
assert results == []
|