合并前复核:补齐急停释放、整轮中止和计划任务时限

Browse Source
This commit is contained in:
yws
2026-10-22 07:32:58 +00:00
parent 8a9495b185
commit a74fda07e2
14 changed files with 324 additions and 111 deletions
+27 -5
View File
@@ -300,8 +300,8 @@ class DriverWiringTest(unittest.TestCase):
def test_actual_task_entry_enables_driver_for_all_and_daily(self): def test_actual_task_entry_enables_driver_for_all_and_daily(self):
from lc_mcp import aalc_task from lc_mcp import aalc_task
for task in ('all', 'daily'): for task, problems in [('all', []), ('daily', []), ('all', ['invalid config'])]:
with self.subTest(task=task): with self.subTest(task=task, problems=problems):
auto, handler_type = vendor_auto() auto, handler_type = vendor_auto()
auto.clear_img_cache = mock.Mock() auto.clear_img_cache = mock.Mock()
auto.click_element = mock.Mock(return_value=False) auto.click_element = mock.Mock(return_value=False)
@@ -328,14 +328,21 @@ class DriverWiringTest(unittest.TestCase):
mock.patch.object(aalc_task, 'install_exact_team_match'), \ mock.patch.object(aalc_task, 'install_exact_team_match'), \
mock.patch.object(aalc_task, 'install_robust_set_foreground'), \ mock.patch.object(aalc_task, 'install_robust_set_foreground'), \
mock.patch.object(aalc_task, 'WindowGuard'), \ mock.patch.object(aalc_task, 'WindowGuard'), \
mock.patch.object(aalc_task.killswitch, 'install') as install_hotkey, \
mock.patch.object(aalc_task, 'log'), \ mock.patch.object(aalc_task, 'log'), \
mock.patch.object(aalc_task.preflight, 'collect', return_value={}), \ mock.patch.object(aalc_task.preflight, 'collect', return_value={}), \
mock.patch.object(aalc_task.preflight, 'desktop_size', return_value=(1920, 1080)), \ mock.patch.object(aalc_task.preflight, 'desktop_size', return_value=(1920, 1080)), \
mock.patch.object(aalc_task.preflight, 'check', return_value=[]), \ mock.patch.object(aalc_task.preflight, 'check', return_value=problems), \
mock.patch.object(di, 'DriverInput', return_value=drv), \ mock.patch.object(di, 'DriverInput', return_value=drv), \
mock.patch.object(ap.DriverClickProxy, '_screen_pos', return_value=(10, 20)): mock.patch.object(ap.DriverClickProxy, '_screen_pos', return_value=(10, 20)):
self.assertEqual(aalc_task.run(task, {}), 0) self.assertEqual(aalc_task.run(task, {}), 3 if problems else 0)
drv.click.assert_called_once_with(10, 20, times=1) install_hotkey.return_value.stop.assert_called_once()
if problems:
drv.click.assert_not_called()
else:
drv.click.assert_called_once_with(10, 20, times=1)
install_hotkey.call_args.kwargs['on_stop']()
drv.emergency_stop.assert_called_once()
def test_disabled_and_simulator_leave_initialization_unchanged(self): def test_disabled_and_simulator_leave_initialization_unchanged(self):
for enabled, simulator in [('0', False), ('1', True)]: for enabled, simulator in [('0', False), ('1', True)]:
@@ -349,6 +356,21 @@ class DriverWiringTest(unittest.TestCase):
class DriverFailureTest(unittest.TestCase): class DriverFailureTest(unittest.TestCase):
def test_emergency_stop_releases_press_and_blocks_subsequent_clicks(self):
drv = di.DriverInput()
drv._open, drv._dll = True, mock.Mock()
with mock.patch.object(drv, 'move_to', return_value=True), \
mock.patch.object(di.time, 'sleep', side_effect=lambda _: drv.emergency_stop()):
self.assertFalse(drv.click(10, 20, times=3))
drv._dll.mouse_down.assert_called_once_with(1)
drv._dll.mouse_up.assert_called_with(1)
self.assertFalse(drv.ready)
self.assertFalse(drv.click(30, 40))
self.assertFalse(drv.move_relative(20, 30))
self.assertFalse(drv.down())
drv._dll.moveR.assert_not_called()
self.assertEqual(drv._pressed, set())
def test_release_even_if_sleep_is_interrupted(self): def test_release_even_if_sleep_is_interrupted(self):
drv = di.DriverInput() drv = di.DriverInput()
drv._open, drv._dll = True, mock.Mock() drv._open, drv._dll = True, mock.Mock()