Fix exploration member selection and automatic reward collection
This commit is contained in:
@@ -136,6 +136,17 @@ class ExplorationTests(unittest.TestCase):
|
||||
self.assertEqual(self.action().kind, "explore_finish")
|
||||
self.assertEqual(self.planner.rows(self.snapshot, policy(), self.ranch)[0]["monster_ids"], [1, 2, 3])
|
||||
|
||||
def test_finished_team_rewards_without_reenabling_restart(self):
|
||||
team = self.snapshot.raw["exploreTeams"][0]
|
||||
self.start_confirmed(team, end=NOW - 1)
|
||||
disabled = ExplorePolicy(True, {"1": ExploreTeamRule(enabled=False, area="1")})
|
||||
actions = self.planner.plan(self.snapshot, disabled, self.ranch)
|
||||
self.assertEqual([(action.kind, action.path) for action in actions],
|
||||
[("explore_finish", "exploreService/finish")])
|
||||
row = self.planner.rows(self.snapshot, disabled, self.ranch)[0]
|
||||
self.assertEqual(row["state"], "可领取")
|
||||
self.assertIn("仍会自动领取奖励", row["reason"])
|
||||
|
||||
def test_active_zero_or_missing_deadline_is_unknown_and_never_finished(self):
|
||||
for value in (None, 0, "", "not-a-time"):
|
||||
with self.subTest(value=value):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user