fix: close batch execution and recovery lifecycle
This commit is contained in:
1 parent
b19afc6a53
commit
d9cf6a07e9
91 files changed
+5779
-454
No files matched your search
@@ -0,0 +1,63 @@
|
||||
"""Task categories follow committed receipts before the whole batch releases."""
|
||||
from threading import Event
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from dx_productivity.trial_task_center.models import TaskStatus
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.batch_resources import BatchResourceCleanupError
|
||||
|
||||
|
||||
def visible_ids(panel):
|
||||
return [panel.list.item(index).data(Qt.ItemDataRole.UserRole) for index in range(panel.list.count())]
|
||||
|
||||
|
||||
def test_completed_task_moves_category_while_next_task_is_still_executing(ui, qtbot, monkeypatch):
|
||||
window=ui.window
|
||||
first,second=ui.tasks
|
||||
waiting,release=Event(),Event()
|
||||
execute=TaskCenterService.execute_quick_run_queue
|
||||
def hold_second(service, task_id, **options):
|
||||
if task_id==second.task_id:
|
||||
waiting.set()
|
||||
assert release.wait(10), 'test did not release its controlled second task'
|
||||
return execute(service, task_id, **options)
|
||||
monkeypatch.setattr(TaskCenterService,'execute_quick_run_queue',hold_second)
|
||||
window._quick_run_confirmer=lambda *_args:True
|
||||
try:
|
||||
window._execute_project_tasks()
|
||||
qtbot.waitUntil(waiting.is_set, timeout=5000)
|
||||
assert ui.store.get_task(first.task_id).status is TaskStatus.COMPLETED
|
||||
ui.open(second)
|
||||
window.task_list.filter.setCurrentIndex(window.task_list.filter.findData('completed'))
|
||||
qtbot.waitUntil(lambda:visible_ids(window.task_list)==[first.task_id], timeout=3000)
|
||||
assert window._workers and window._batch_stop is not None
|
||||
assert window._task_id==second.task_id
|
||||
assert ui.store.get_task(second.task_id).status is not TaskStatus.COMPLETED
|
||||
assert len(ui.calls)==1
|
||||
finally:
|
||||
release.set()
|
||||
ui.settle()
|
||||
assert len(ui.calls)==2
|
||||
assert set(visible_ids(window.task_list))=={first.task_id,second.task_id}
|
||||
|
||||
|
||||
def test_resource_error_after_business_completion_refreshes_categories(ui):
|
||||
window=ui.window
|
||||
first=ui.tasks[0]
|
||||
window._begin_run(first.task_id)
|
||||
window._quick_run_timer.stop() # The final error path must refresh even without a timer tick.
|
||||
window.task_list.filter.setCurrentIndex(window.task_list.filter.findData('completed'))
|
||||
def execute_then_fail_release():
|
||||
progress=ui.service.quick_run_progress(first.task_id)
|
||||
expected=(str(progress.next_project_path),progress.next_old_part_number,
|
||||
progress.next_new_part_number,'preserve')
|
||||
ui.service.execute_quick_run_queue(first.task_id,expected_item=expected,
|
||||
stop_event=window._batch_stop)
|
||||
raise BatchResourceCleanupError('controlled desktop release failure after task completion')
|
||||
window._run_async(execute_then_fail_release,lambda _:None,expected_task_id=first.task_id)
|
||||
ui.settle()
|
||||
assert ui.store.get_task(first.task_id).status is TaskStatus.COMPLETED
|
||||
assert visible_ids(window.task_list)==[first.task_id]
|
||||
assert window._batch_stop is None
|
||||
assert len(ui.calls)==1
|
||||
assert 'controlled desktop release failure' in window.run_panel.operator_band.text()
|
||||
Reference in new issue
Block a user