37 lines
2.0 KiB
Python
37 lines
2.0 KiB
Python
from copy import deepcopy
|
|
from types import SimpleNamespace
|
|
import unittest
|
|
|
|
from ranch_assistant.battle_messages import battle_message
|
|
from ranch_assistant.progression_gui import prepare_progression_views
|
|
|
|
|
|
class BattleMessagesTests(unittest.TestCase):
|
|
def test_objective_blocker_is_chinese_and_not_reported_as_defeat(self):
|
|
reason = "Non-elimination win/loss objective is unsupported; Protected/destroy objective units are unsupported"
|
|
source = [{"task_type_id": "1002002", "category": "mainline", "supported": False,
|
|
"block_reason": reason, "step_number": 2, "total_steps": 2}]
|
|
original = deepcopy(source)
|
|
engine = SimpleNamespace(snapshot=None, progression_rows=lambda: source, progression_records=lambda: [])
|
|
detail = prepare_progression_views(engine).tasks[0]["detail"]
|
|
self.assertIn("保护或摧毁指定目标", detail)
|
|
self.assertNotIn("unsupported", detail)
|
|
self.assertNotIn("打不过", detail)
|
|
self.assertEqual(source, original)
|
|
|
|
def test_known_and_future_diagnostics_do_not_show_raw_english(self):
|
|
for text in ("Unsupported monster controller: buffMovie", "Unsupported battle triggers: bossWave",
|
|
"Invalid numeric field: mon.hp", "Some future unsupported mechanic"):
|
|
with self.subTest(text=text):
|
|
self.assertRegex(battle_message(text), r"[\u3400-\u9fff]")
|
|
self.assertNotEqual(battle_message(text), text)
|
|
|
|
def test_only_actual_losses_show_cannot_win(self):
|
|
engine = SimpleNamespace(snapshot=None, progression_rows=lambda: [], progression_records=lambda: [
|
|
{"outcome": "loss", "message": "实验模型战败(近似);已停止此轮任务推进"},
|
|
{"outcome": "unsupported", "reason": "Unsupported monster controller: buffMovie"}])
|
|
rows = prepare_progression_views(engine).records
|
|
self.assertEqual(rows[0]["values"][4], "打不过")
|
|
self.assertIn("打不过", rows[0]["detail"])
|
|
self.assertNotIn("打不过", rows[1]["detail"])
|