Fix exploration member selection and automatic reward collection

This commit is contained in:
AttilaNet
2026-11-09 15:10:16 +08:00
parent eaaad3488b
commit 5d2da97b90
5 changed files with 91 additions and 11 deletions
+51 -1
View File
@@ -14,7 +14,7 @@ from PySide6.QtTest import QTest
from ranch_assistant import gui
from ranch_assistant.exploration import ExplorePlanner
from ranch_assistant.tests.test_core import workspace_temp
from ranch_assistant.tests.test_exploration import AREAS, make_snapshot, policy
from ranch_assistant.tests.test_exploration import AREAS, NOW, make_snapshot, policy
class ExplorationGuiTests(unittest.TestCase):
@@ -61,6 +61,56 @@ class ExplorationGuiTests(unittest.TestCase):
def controls(self):
return self.window.exploration_table._controls["1"]
def test_initial_area_selection_loads_members_then_preserves_draft_on_refresh(self):
window = self.window
window.apply_explore_policy(policy(area=""))
window.engine.explore_policy = policy(area="")
window.refresh_exploration()
self.wait(window, lambda: not window.busy)
control = self.controls()
self.assertEqual(control["area"].currentData(), "")
self.assertTrue(all(combo.count() == 1 for combo in control["members"]))
control["area"].setCurrentIndex(control["area"].findData("1"))
self.wait(window, lambda: all(combo.findData(1) >= 0 for combo in control["members"]))
saved = []
with patch.object(window, "settings_changed", side_effect=lambda: saved.append(window.read_explore_policy().to_dict())):
control["members"][0].setCurrentIndex(control["members"][0].findData(1))
self.assertEqual(window._exploration_drafts["1"], [1, None, None])
self.assertEqual(window.read_explore_policy().teams["1"].monsters, [])
window.refresh_exploration()
self.wait(window)
control = self.controls()
self.assertEqual([combo.currentData() for combo in control["members"]], [1, None, None])
self.assertEqual(window._exploration_drafts["1"], [1, None, None])
self.assertFalse(saved)
control["members"][1].setCurrentIndex(control["members"][1].findData(2))
self.assertFalse(saved)
control["members"][2].setCurrentIndex(control["members"][2].findData(3))
self.assertEqual([combo.currentData() for combo in control["members"]], [1, 2, 3])
self.assertEqual(window.read_explore_policy().teams["1"].monsters, [1, 2, 3])
self.assertNotIn("1", window._exploration_drafts)
self.assertEqual(len(saved), 1)
self.assertEqual(saved[0]["teams"]["1"]["monsters"], [1, 2, 3])
def test_active_snapshot_deadline_arms_without_an_existing_plan(self):
window = self.window
snapshot = window.engine.snapshot
snapshot.raw["exploreTeams"][0].update(
status=1, area="1", monsters="1,2,3", endTime=(NOW + 60) * 1000)
window.latest_render = (snapshot, [])
window.monitoring = True
window.set_strategy_checked(True)
window.explore_enabled.setChecked(True)
window.next_explore = float("inf")
now = time.monotonic()
with patch.object(gui.time, "monotonic", return_value=now):
window.arm_extended_automation()
self.assertAlmostEqual(window.next_explore, now + 61, places=2)
def test_real_window_three_selections_and_busy_policy_queue(self):
window = self.window
window.refresh_exploration()