fix: fix test patching in campaign_loop and malformed entry filtering in campaign_state
- 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:
@@ -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",
|
||||
|
||||
@@ -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", "")),
|
||||
|
||||
Reference in New Issue
Block a user