fix: fix test patching in campaign_loop and malformed entry filtering in campaign_state
Some checks failed
Tests / lint (pull_request) Failing after 29s
Tests / test (pull_request) Has been skipped

- Remove redundant local GabsClient import inside run() that bypassed
  unittest.mock patches in TestCampaignLoopRun tests
- Skip nearby_party entries missing a valid 'id' field in parse_campaign_state
  so malformed dicts like {"bad": "data"} are dropped rather than creating
  empty NearbyParty objects

Fixes #1094

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-23 21:34:18 -04:00
parent 46ef9d3aba
commit 1a4653570e
2 changed files with 3 additions and 2 deletions

View File

@@ -121,8 +121,6 @@ class CampaignLoop:
Returns the list of tick results (for testing / benchmarking).
Runs until M2 complete, externally stopped, or max_ticks reached.
"""
from bannerlord.gabs_client import GabsClient
self._running = True
logger.info(
"CampaignLoop starting — gabs=%s:%d tick=%.1fs",

View File

@@ -168,6 +168,9 @@ def parse_campaign_state(raw: dict[str, Any]) -> CampaignState:
nearby_parties = []
for p in raw.get("nearby_parties", []):
try:
if not isinstance(p, dict) or not p.get("id"):
logger.debug("Skipping malformed nearby_party entry: missing id")
continue
nearby_parties.append(
NearbyParty(
party_id=str(p.get("id", "")),