mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-23 22:06:28 +01:00
fix: remove dead code in unplayable_reason; add coverage for playable path
This commit is contained in:
parent
ded3b9ed30
commit
f4a188068f
28
docs/superpowers/evidence/protondb-coverage-fix.json
Normal file
28
docs/superpowers/evidence/protondb-coverage-fix.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"intent": "Remove unreachable dead code in unplayable_reason and add coverage for the is_playable=True path.",
|
||||||
|
"scope": [
|
||||||
|
"python_pkg/steam_backlog_enforcer/protondb.py",
|
||||||
|
"python_pkg/steam_backlog_enforcer/tests/test_protondb.py"
|
||||||
|
],
|
||||||
|
"changes": [
|
||||||
|
"Replaced conditional 'if tier_rank > min_rank and trend_rank > min_rank: return ...' + dead fallback 'return fails ProtonDB rule' with a direct return, since the condition is always True in that branch",
|
||||||
|
"Added test_unplayable_reason_empty_when_playable to cover the return '' path"
|
||||||
|
],
|
||||||
|
"verification": [
|
||||||
|
{
|
||||||
|
"command": "pre-commit run --files protondb.py tests/test_protondb.py",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "All hooks passed on second run (ruff auto-fixed unused variable on first run)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "pytest python_pkg/steam_backlog_enforcer/tests/test_protondb.py",
|
||||||
|
"result": "pass",
|
||||||
|
"evidence": "31 passed, 0 failed"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"risks": ["None — dead code removal only, no logic change"],
|
||||||
|
"rollback": [
|
||||||
|
"Revert protondb.py to restore the if-condition and fallback return",
|
||||||
|
"Remove the new test"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -90,7 +90,7 @@ class ProtonDBRating:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
tier_rank = TIER_ORDER.get(self.tier, 99)
|
tier_rank = TIER_ORDER.get(self.tier, 99)
|
||||||
min_rank = TIER_ORDER[MIN_PLAYABLE_TIER]
|
TIER_ORDER[MIN_PLAYABLE_TIER]
|
||||||
silver_rank = TIER_ORDER["silver"]
|
silver_rank = TIER_ORDER["silver"]
|
||||||
|
|
||||||
if not self.trending_tier:
|
if not self.trending_tier:
|
||||||
@ -99,9 +99,7 @@ class ProtonDBRating:
|
|||||||
trend_rank = TIER_ORDER.get(self.trending_tier, 99)
|
trend_rank = TIER_ORDER.get(self.trending_tier, 99)
|
||||||
if tier_rank > silver_rank or trend_rank > silver_rank:
|
if tier_rank > silver_rank or trend_rank > silver_rank:
|
||||||
return f"below silver ({self.tier}/{self.trending_tier})"
|
return f"below silver ({self.tier}/{self.trending_tier})"
|
||||||
if tier_rank > min_rank and trend_rank > min_rank:
|
return f"no gold tier ({self.tier}/{self.trending_tier})"
|
||||||
return f"no gold tier ({self.tier}/{self.trending_tier})"
|
|
||||||
return "fails ProtonDB rule"
|
|
||||||
|
|
||||||
|
|
||||||
def _load_cache() -> dict[str, Any]:
|
def _load_cache() -> dict[str, Any]:
|
||||||
|
|||||||
@ -100,6 +100,10 @@ class TestProtonDBRating:
|
|||||||
r = ProtonDBRating(app_id=1, tier="gold", trending_tier="bronze")
|
r = ProtonDBRating(app_id=1, tier="gold", trending_tier="bronze")
|
||||||
assert "below silver" in r.unplayable_reason
|
assert "below silver" in r.unplayable_reason
|
||||||
|
|
||||||
|
def test_unplayable_reason_empty_when_playable(self) -> None:
|
||||||
|
r = ProtonDBRating(app_id=1, tier="gold")
|
||||||
|
assert r.unplayable_reason == ""
|
||||||
|
|
||||||
|
|
||||||
class TestProtonDBCache:
|
class TestProtonDBCache:
|
||||||
"""Tests for cache I/O."""
|
"""Tests for cache I/O."""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user