mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-21 18:52:18 +01:00
Tests are now linted by the 10.00 gate (ignore-paths dropped), with no per-test disables. CtlServer/DaemonControl members the tests drive are public (renamed, behaviour unchanged); SteamAPIClient._get takes its params explicitly, as every caller already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Tests for hltb module - part 3 (fetch_hltb_times)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from steam_backlog_enforcer._hltb_types import HLTBResult
|
|
from steam_backlog_enforcer.hltb import fetch_hltb_times
|
|
|
|
|
|
class TestFetchHltbTimes:
|
|
"""Tests for fetch_hltb_times."""
|
|
|
|
def test_empty(self) -> None:
|
|
"""No games means no lookups and an empty result."""
|
|
assert fetch_hltb_times([]) == []
|
|
|
|
def test_calls_batch(self) -> None:
|
|
"""Results from the batch fetch are returned."""
|
|
mock_result = HLTBResult(
|
|
app_id=440, game_name="TF2", completionist_hours=50.0, similarity=1.0
|
|
)
|
|
with patch(
|
|
"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:
|
|
"""Without a cache, an empty batch yields no results."""
|
|
with patch(
|
|
"steam_backlog_enforcer.hltb._fetch_batch",
|
|
return_value=[],
|
|
):
|
|
results = fetch_hltb_times([(440, "TF2")])
|
|
assert results == []
|
|
|
|
def test_explicit_cache(self) -> None:
|
|
"""A passed cache does not invent results the batch did not return."""
|
|
with patch(
|
|
"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 == []
|