steam-backlog-enforcer/steam_backlog_enforcer/tests/test_hltb_part3.py
Krzysztof kuhy Rudnicki 7323c896f6
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (push) Waiting to run
Tests / test (push) Waiting to run
Import split-out names from the modules that own them; drop the four lazy facades
hltb, _cmd_done, _whitelist and _actions each kept a module __getattr__
that served names moved out in the 250-line split, via importlib to
dodge the resulting import cycle. pylint cannot see through that, and
graded every such import as no-name-in-module (26 of them). The 32
import statements now name the real module; with nothing left going
through the facades, they are gone.

Also the pylint hook on 4.0.8 with the source-only scope config, the
three implicit-booleaness disables the reference repos carry, the
http.server do_GET admission, and the third-party pins the hook was
missing (aiohttp, websockets, howlongtobeatpy). Gate still 8.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HHCbkJWXHjtTUaqvnHRAqA
2026-09-12 20:22:44 +02:00

44 lines
1.3 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:
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(
"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(
"steam_backlog_enforcer.hltb._fetch_batch",
return_value=[],
):
results = fetch_hltb_times([(440, "TF2")])
assert results == []
def test_explicit_cache(self) -> None:
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 == []