fix(ui): guard destroyed windows and migrate stale workflow regressions
This commit is contained in:
1 parent
d12478efd8
commit
e2f76c3387
10 files changed
+333
-1321
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# 可选封装与候选发布验收
|
||||
|
||||
## 本轮要求
|
||||
|
||||
用户确认三项:目标封装可选;排查并清理回归失败项;从最终冻结候选 ZIP 解压后验收 BOM、替换保存、旧数据升级及后台资源释放。本轮不创建远端 Release、不覆盖 V1.1.2 附件,不修改原工程或中央库,不改未跟踪 feedback。
|
||||
|
||||
未指定封装时,工具不读封装目录、不主动覆写 Cell Name,可后续与中心库同步;原生 Replace Part 本身可能更新库关联属性,不承诺封装始终保持旧值。明确选择封装时继续核验完整库证据、写入并保存重开检查。
|
||||
|
||||
## 回归失败归因与处理
|
||||
|
||||
| 原失败 | 原因及处理 | 证据 |
|
||||
| --- | --- | --- |
|
||||
| 构建检查 3 项 VBS 保护失败 | 抽取生产函数的测试夹具漏载新增 QPTargetCell,出现 VBScript 类型不匹配;补载真实函数,保留全部原断言 | release-candidate-gate-initial-20261019.xml;release-safety-fixes-20261019.xml |
|
||||
| 旧彻底删除租约检查 | 旧测试要求执行期间绕过互斥,现有安全规则禁止修改;改为锁内拒绝、关系不变、释放后正常删除 | release-delete-final-20261019.xml:8 passed;包含 3 项未决队列证据保留 |
|
||||
| 旧队列功能检查 | 重新运行,无当前失败,不因历史报告改动生产队列 | release-legacy-quick-run-initial-20261019.xml:34 passed;批处理功能初跑 59 passed,另有租约及性能失败 |
|
||||
| 旧 UI 导入错误和 42 项失败 | 引用了已移除导出、QTableWidget 工程链表、扫描/手动跳过/单次无备份按钮、内嵌日志、同步读取、重叠 mutation worker;迁移到当前单工程任务、QTableView、目录创建弹窗、可回收日志窗口与串行 mutation 语义 | release-legacy-ui-initial-20261019.xml;release-ui-migrated-final-20261019.xml:23 passed |
|
||||
| 销毁窗口后后台回调 | 补回销毁测试后发现真实缺陷:success/failed/finished 闭包访问已删除控件;增加 QObject 有效性检查,结束时仍移除 worker,禁止触碰已删除控件 | release-ui-destruction-20261019.xml 为失败记录;release-ui-lifecycle-final-20261019.xml:54 passed,含成功/失败两个销毁场景 |
|
||||
| 初次构建无法收集 XLSX 测试 | 仓库 .venv 缺 openpyxl,构建安全停止;后续明确使用依赖齐全的安装版 Python 3.12,不跳过构建检查 | release-candidate-build-20261019.log 保留失败;后续构建另存日志 |
|
||||
|
||||
以上检查范围有重叠,不相加当独立总数。旧 UI 的 47 个用例没有被称为全部修复后逐项通过:已移除界面不再保留对应布局断言,仍有效的功能和安全意图迁移到当前 UI;新的 tests/ui 共 25 项(23 项加两个销毁分支)。没有 skip、xfail、放宽性能阈值或删掉有效证据保留检查来制造通过。
|
||||
|
||||
## UI 迁移覆盖对照
|
||||
|
||||
| 原意图 | 当前检查位置 |
|
||||
| --- | --- |
|
||||
| 读取/选择工程与位号、BOM 原地编辑 | tests/v1_1/test_project_task_ui.py;test_ui_workspace.py |
|
||||
| 搜索、排序、回收站和确认删除 | tests/v1_1/test_ui_remediation.py;tests/ui/test_permanent_delete_ui.py |
|
||||
| 确认前不执行、未命中完成、Value 策略变化停止旧确认 | tests/ui/test_trial_task_center_workflow.py |
|
||||
| 规则勾选持久化、任务 Value 独立 | tests/ui/test_trial_task_center_workflow.py;test_value_options_layout.py |
|
||||
| 已完成任务状态、重试、重复执行新轮次 | tests/v1_1/test_ui_batch_retry.py;test_new_round.py |
|
||||
| 任务切换丢弃旧查询、执行期间只读浏览、归属不丢失 | tests/v1_1/test_ui_responsiveness.py |
|
||||
| 常规 mutation 禁止重入,退出等待安全收尾,强制销毁回调 | tests/ui/test_trial_task_center_workflow.py;tests/v1_1/test_ui_remediation.py |
|
||||
| 错误编号及日志格式、按需创建/关闭/重新打开日志 | tests/ui/test_execution_feedback.py;tests/v1_1/test_lazy_components.py;test_execution_results_view.py |
|
||||
| 小窗口和布局持久化 | tests/ui/test_value_options_layout.py;tests/v1_1/test_ui_workspace.py |
|
||||
|
||||
## 验收进度
|
||||
|
||||
源码修复与相关回归已完成;冻结包、多工程实机、升级及性能结果将在完成后填写。此处尚不宣称正式发布就绪。
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Single-project task presentation; persistence and CAD remain in the service."""
|
||||
from __future__ import annotations
|
||||
from threading import Event
|
||||
from shiboken6 import isValid
|
||||
import time
|
||||
from PySide6.QtCore import QElapsedTimer, QSettings, QSignalBlocker, QThreadPool, QTimer, Qt
|
||||
from PySide6.QtWidgets import (QApplication, QDialog, QHBoxLayout, QMainWindow, QMessageBox,
|
||||
@@ -717,7 +718,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.plan_panel._summary()
|
||||
operation_error = None
|
||||
def valid():
|
||||
return not self._closed and generation == self._generation and (retain_result or execution or expected_task_id is None or expected_task_id == self._task_id)
|
||||
return isValid(self) and not self._closed and generation == self._generation and (retain_result or execution or expected_task_id is None or expected_task_id == self._task_id)
|
||||
def succeeded(result):
|
||||
nonlocal operation_error
|
||||
if valid():
|
||||
@@ -734,6 +735,8 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
def failed(error):
|
||||
nonlocal operation_error
|
||||
operation_error = error
|
||||
if not isValid(self) or self._closed:
|
||||
return
|
||||
self.operation_state = self.operation_state.finish(error)
|
||||
if self._close_saving or not (isinstance(error, TaskCenterError) and error.code == 'operation_cancelled'):
|
||||
self._close_pending = False
|
||||
@@ -746,6 +749,8 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self._show_error(error, owner_task_id=owner)
|
||||
def finished():
|
||||
self._workers.discard(worker)
|
||||
if not isValid(self) or self._closed:
|
||||
return
|
||||
self.plan_panel.finish_operation(error=operation_error)
|
||||
self._close_saving = False
|
||||
if self._close_pending and not self._closed:
|
||||
|
||||
@@ -69,11 +69,15 @@ def test_failed_delete_rolls_back_all_child_deletions(populated):
|
||||
assert store.get_task(task.task_id).status is TaskStatus.DELETED
|
||||
|
||||
|
||||
def test_purge_deleted_task_bypasses_execution_lease(populated):
|
||||
def test_purge_deleted_task_is_blocked_during_execution_and_works_after_release(populated):
|
||||
store, service, task, _, _, data = populated
|
||||
service.delete_task(task.task_id)
|
||||
with _quick_run_lease(data):
|
||||
assert service.purge_task(task.task_id, confirmed=True) == task.task_id
|
||||
with pytest.raises(TaskCenterError, match='quick_run_busy'):
|
||||
service.purge_task(task.task_id, confirmed=True)
|
||||
assert store.get_task(task.task_id).status is TaskStatus.DELETED
|
||||
assert len(store.list_rules(task.task_id)) == 1
|
||||
assert service.purge_task(task.task_id, confirmed=True) == task.task_id
|
||||
with pytest.raises(TaskCenterError, match='unknown_task'):
|
||||
store.get_task(task.task_id)
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""Current one-project UI fixtures; queries must settle before assertions."""
|
||||
import os
|
||||
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
|
||||
from types import SimpleNamespace
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import pytest
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ui(qtbot, tmp_path):
|
||||
root = tmp_path/'projects'
|
||||
for name in ('Board-A','Board-B'):
|
||||
project=root/name/'board.prj';project.parent.mkdir(parents=True)
|
||||
project.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n')
|
||||
data=tmp_path/'data'
|
||||
calls=[]
|
||||
def worker(command, timeout):
|
||||
queue=Path(command[3]);job=command[-1];calls.append(job)
|
||||
with (queue/'status.tsv').open('a',encoding='utf-8') as stream:
|
||||
stream.write(f'{job}\tno_match\tbatch_closed\tNo matching components\n')
|
||||
return subprocess.CompletedProcess(command,0,'','')
|
||||
preparer=QuickRunPreparer(data,process_runner=worker,
|
||||
cscript_resolver=lambda:Path('cscript.exe'),sheet_discoverer=lambda _path:(('MAIN','1'),))
|
||||
store=TaskStore(tmp_path/'tasks.db')
|
||||
service=TaskCenterService(store,configure_logging(data),quick_run_preparer=preparer)
|
||||
tasks=service.create_project_tasks(root)
|
||||
service.add_rule(tasks[0].task_id,'OLD','NEW')
|
||||
window=TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window);window.show()
|
||||
def settle():
|
||||
qtbot.waitUntil(lambda:not window._workers and not window._task_query.busy
|
||||
and not window._context_query.busy and not window._feedback_query.busy
|
||||
and not window._log_presenter.query.busy,timeout=5000)
|
||||
def open_task(task):
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda:not window._context_query.busy and not window._loading,timeout=5000)
|
||||
assert window._context and window._context.task.task_id==task.task_id
|
||||
open_task(tasks[0])
|
||||
yield SimpleNamespace(window=window,service=service,store=store,tasks=tasks,
|
||||
calls=calls,settle=settle,open=open_task,data=data)
|
||||
settle();window.plan_panel.discard_all();window.close();store.close()
|
||||
@@ -1,22 +1,8 @@
|
||||
from pathlib import Path
|
||||
"""Readable logs and execution feedback on the current project-task interface."""
|
||||
import json
|
||||
import subprocess
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.ui import main_window
|
||||
from dx_productivity.trial_task_center.ui.main_window import (
|
||||
TrialTaskCenterWindow,
|
||||
_aligned_log_line,
|
||||
_format_task_log_lines,
|
||||
_nc_sync_log_lines,
|
||||
from dx_productivity.trial_task_center.ui.messages import (
|
||||
_aligned_log_line, _format_task_log_lines, _nc_sync_log_lines,
|
||||
)
|
||||
|
||||
|
||||
@@ -59,259 +45,46 @@ def test_log_operation_column_stays_aligned_for_long_names():
|
||||
assert 'operation_name_that_is_lo...' in line
|
||||
|
||||
|
||||
def test_running_batch_rebuilds_project_table_only_at_project_boundaries(qtbot, tmp_path, monkeypatch):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Refresh boundary')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
window._active_quick_run_task_id = task.task_id
|
||||
window._quick_run_elapsed.start()
|
||||
window._batch_rendered = (task.task_id, 0)
|
||||
renders = []
|
||||
monkeypatch.setattr(window, '_populate_projects', lambda: renders.append('render'))
|
||||
monkeypatch.setattr(window, '_update_gates', lambda: None)
|
||||
|
||||
progress = SimpleNamespace(
|
||||
completed_items=1,
|
||||
total_items=3,
|
||||
no_match_items=1,
|
||||
completed_project_paths=(),
|
||||
)
|
||||
service._batch_feedback = (task.task_id, progress, '正在处理')
|
||||
window._update_quick_run_elapsed()
|
||||
assert renders == []
|
||||
assert '已处理 1/3 项' in window.run_panel.queue_summary.text()
|
||||
|
||||
progress.completed_items = 2
|
||||
progress.completed_project_paths = (tmp_path / 'project.prj',)
|
||||
service._batch_feedback = (task.task_id, progress, '工程已完成')
|
||||
window._update_quick_run_elapsed()
|
||||
assert renders == ['render']
|
||||
window.close()
|
||||
store.close()
|
||||
def test_preflight_error_keeps_reason_and_stable_id_in_operator_feedback(ui):
|
||||
error=TaskCenterError('quick_run_preflight','target library row was not found')
|
||||
ui.window._show_error(error)
|
||||
text=ui.window.run_panel.operator_band.text()
|
||||
assert error.error_id in text and error.message in text
|
||||
assert ui.window.run_panel.operator_band.property('state')=='error'
|
||||
assert error.error_id in ui.window._log_presenter.log_text
|
||||
|
||||
|
||||
@pytest.mark.parametrize('code', ['quick_run_session', 'quick_run_preflight'])
|
||||
def test_pre_mutation_failure_does_not_keep_running_label_or_claim_possible_writes(qtbot, tmp_path, code):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Diagnostic')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
window.run_panel.execution_status.setText('正在执行')
|
||||
window._show_error(TaskCenterError(code, 'test preflight'))
|
||||
assert '执行已停止' in window.run_panel.execution_status.text()
|
||||
assert '尚未开始替换' in window.run_panel.execution_status.text()
|
||||
assert '图页可能已被修改' not in window.run_panel.operator_band.text()
|
||||
assert '不能假定图页未修改' not in window.run_panel.operator_band.text()
|
||||
window.close()
|
||||
store.close()
|
||||
|
||||
|
||||
def test_backup_failure_exposes_one_shot_continue_button(qtbot, tmp_path, monkeypatch):
|
||||
root = tmp_path / 'projects'
|
||||
root.mkdir()
|
||||
(root / 'one.prj').touch()
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Backup override')
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, 'OLD', 'NEW')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
|
||||
assert window.run_panel.continue_without_backup_button.isHidden()
|
||||
window._show_error(TaskCenterError('quick_run_backup', 'simulated backup failure'))
|
||||
assert not window.run_panel.continue_without_backup_button.isHidden()
|
||||
assert window.run_panel.continue_without_backup_button.isEnabled()
|
||||
|
||||
dispatched = []
|
||||
monkeypatch.setattr(
|
||||
QMessageBox,
|
||||
'warning',
|
||||
lambda *_args, **_kwargs: QMessageBox.StandardButton.Yes,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
window,
|
||||
'_start_quick_run_queue',
|
||||
lambda task_id, expected_item, **options: dispatched.append((task_id, expected_item, options)),
|
||||
)
|
||||
window._continue_without_backup()
|
||||
|
||||
assert dispatched[0][0] == task.task_id
|
||||
assert dispatched[0][1][1:] == ('OLD', 'NEW', 'preserve')
|
||||
assert dispatched[0][2] == {'continue_after_backup_failure': True}
|
||||
window.close()
|
||||
store.close()
|
||||
|
||||
|
||||
def test_non_backup_failure_does_not_expose_backup_override(qtbot, tmp_path):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('No backup override')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
|
||||
window._show_error(TaskCenterError('quick_run_preflight', 'simulated preflight failure'))
|
||||
|
||||
assert window.run_panel.continue_without_backup_button.isHidden()
|
||||
window.close()
|
||||
store.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('displayed', [False, True])
|
||||
@pytest.mark.parametrize('state', ['no_match', 'restored_ok'])
|
||||
def test_confirmation_matches_execution_and_zero_match_is_a_completed_skip(qtbot, tmp_path, monkeypatch, displayed, state):
|
||||
data = tmp_path / 'data'
|
||||
executed = []
|
||||
messages = []
|
||||
|
||||
def worker(command, timeout):
|
||||
row = (data / 'quick-run/command.tsv').read_text(encoding='utf-8').splitlines()[1].split('\t')
|
||||
executed.append(row[-1])
|
||||
with (data / 'quick-run/status.tsv').open('a', encoding='utf-8') as handle:
|
||||
if state == 'restored_ok':
|
||||
handle.write(f'{row[1]}\tawaiting_native_replace\t\tcaptured\n')
|
||||
terminal = 'saved_ok' if state == 'restored_ok' else state
|
||||
handle.write(f'{row[1]}\t{terminal}\tbatch_closed\tcurrent sheet checked\n')
|
||||
return subprocess.CompletedProcess(command, 0, '', '')
|
||||
|
||||
class ConfirmBox:
|
||||
Icon = QMessageBox.Icon
|
||||
ButtonRole = QMessageBox.ButtonRole
|
||||
|
||||
def __init__(self, icon, title, text, parent=None):
|
||||
messages.append(text)
|
||||
self.buttons = []
|
||||
|
||||
def addButton(self, text, role):
|
||||
button = object()
|
||||
self.buttons.append(button)
|
||||
return button
|
||||
|
||||
def exec(self):
|
||||
return 0
|
||||
|
||||
def clickedButton(self):
|
||||
return self.buttons[0]
|
||||
|
||||
source = Path(__file__).resolve().parents[2] / 'integration/dxdesigner795/QuickPartReplace.vbs'
|
||||
preparer = QuickRunPreparer(data, script_source=source, process_runner=worker,
|
||||
cscript_resolver=lambda: Path('C:/Windows/SysWOW64/cscript.exe'),
|
||||
sheet_discoverer=lambda project: (('Main', '1'),))
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(data), quick_run_preparer=preparer)
|
||||
task = service.create_task('Policy consistency')
|
||||
project_root = tmp_path / 'projects'
|
||||
project_root.mkdir()
|
||||
(project_root / 'one.prj').touch()
|
||||
project = service.scan_projects(task.task_id, project_root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, 'OLD', 'NEW')
|
||||
service.set_copy_part_number_to_value(task.task_id, displayed)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
other_store = TaskStore(tmp_path / 'tasks.db')
|
||||
other = TaskCenterService(other_store, configure_logging(data))
|
||||
try:
|
||||
other.set_copy_part_number_to_value(task.task_id, not displayed)
|
||||
assert window.run_panel.copy_value_check.isChecked() is displayed
|
||||
monkeypatch.setattr(main_window, 'QMessageBox', ConfirmBox)
|
||||
window._prepare_quick_run()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=10000)
|
||||
expected = 'preserve' if displayed else 'part_label'
|
||||
shown = '保留原 Value,不额外改写' if displayed else '复制目标 Part Label'
|
||||
assert shown in messages[0]
|
||||
assert '枚举工程内全部原理图页' in messages[0]
|
||||
assert '图页清单在替换前固定' in messages[0]
|
||||
assert executed == [expected]
|
||||
assert service.quick_run_progress(task.task_id).queue_complete
|
||||
if state == 'no_match':
|
||||
assert '成功 0,失败 0,未命中 1' in window.run_panel.operator_band.text()
|
||||
assert '全工程图页队列完成' in window.run_panel.operator_band.text()
|
||||
assert window.run_panel.operator_band.property('state') == 'success'
|
||||
assert window.run_panel.execution_status.text() == '队列已完成'
|
||||
assert '未命中 1' in window.run_panel.queue_summary.text()
|
||||
assert '全工程图页队列完成' in window.run_panel.operator_band.text()
|
||||
assert window.project_table.item(0, 3).text() == '未命中跳过'
|
||||
assert '未作替换' in window.project_table.item(0, 4).text()
|
||||
else:
|
||||
assert '成功 1,失败 0,未命中 0' in window.run_panel.operator_band.text()
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
assert '尚未' not in window.run_panel.operator_band.text()
|
||||
assert '成功项已保存' in window.run_panel.operator_band.text()
|
||||
assert '已保存' in window.project_table.item(0, 4).text()
|
||||
finally:
|
||||
window.close()
|
||||
other_store.close()
|
||||
store.close()
|
||||
|
||||
|
||||
def test_closing_during_execution_requests_boundary_pause(qtbot, tmp_path):
|
||||
def test_running_feedback_names_owner_and_keeps_navigation_available(ui,qtbot):
|
||||
from threading import Event
|
||||
from PySide6.QtGui import QCloseEvent
|
||||
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
stop = Event()
|
||||
window._batch_stop = stop
|
||||
window._button_generations[window.run_panel.quick_run_button] = 1
|
||||
close_event = QCloseEvent()
|
||||
release,started=Event(),Event()
|
||||
window=ui.window;task=ui.tasks[0]
|
||||
def work():
|
||||
started.set();assert release.wait(5)
|
||||
window._begin_run(task.task_id)
|
||||
try:
|
||||
window.closeEvent(close_event)
|
||||
assert not close_event.isAccepted()
|
||||
assert stop.is_set()
|
||||
assert not window.run_panel.stop_queue_button.isEnabled()
|
||||
assert '正在完成当前项' in window.run_panel.stop_queue_button.text()
|
||||
window._run_async(work,lambda _:window._finish_run(),expected_task_id=task.task_id)
|
||||
qtbot.waitUntil(started.is_set)
|
||||
ui.open(ui.tasks[1])
|
||||
assert window.task_list.list.isEnabled()
|
||||
assert not window.add_mapping_button.isEnabled()
|
||||
assert not window.run_panel.quick_run_button.isEnabled()
|
||||
window._pause_queue()
|
||||
assert window._batch_stop.is_set()
|
||||
finally:
|
||||
window._button_generations.clear()
|
||||
window._batch_stop = None
|
||||
window.close()
|
||||
store.close()
|
||||
release.set()
|
||||
ui.settle()
|
||||
assert window._batch_stop is None and window._task_id==ui.tasks[1].task_id
|
||||
|
||||
|
||||
def test_manual_skip_is_disabled_while_automatic_worker_runs(qtbot, tmp_path):
|
||||
from threading import Event
|
||||
|
||||
root = tmp_path / 'projects'
|
||||
root.mkdir()
|
||||
(root / 'one.prj').touch()
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Automatic queue')
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, 'OLD', 'NEW')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
window.project_table.selectRow(0)
|
||||
window._batch_stop = Event()
|
||||
window._button_generations[window.run_panel.quick_run_button] = 1
|
||||
try:
|
||||
window._update_gates()
|
||||
assert not window.skip_button.isEnabled()
|
||||
assert not window.retry_button.isEnabled()
|
||||
assert window.project_table.isEnabled()
|
||||
assert window.mapping_table.isEnabled()
|
||||
assert not window.project_table.cellWidget(0, 0).isEnabled()
|
||||
assert not window.mapping_table.cellWidget(0, 4).findChild(main_window.QCheckBox).isEnabled()
|
||||
finally:
|
||||
window._button_generations.clear()
|
||||
window._batch_stop = None
|
||||
window.close()
|
||||
store.close()
|
||||
def test_log_window_is_created_on_demand_and_can_be_reopened(ui):
|
||||
window=ui.window
|
||||
assert window.run_panel.log_dialog is None
|
||||
window._show_task_log();ui.settle()
|
||||
dialog=window.run_panel.log_dialog
|
||||
assert dialog is not None and dialog.isVisible()
|
||||
dialog.close();ui.settle()
|
||||
assert window.run_panel.log_dialog is None
|
||||
assert not window.run_panel.toggle_log_button.isChecked()
|
||||
window._show_task_log();ui.settle()
|
||||
assert window.run_panel.log_dialog is not None
|
||||
assert window.run_panel.log_dialog is not dialog
|
||||
@@ -1,83 +1,41 @@
|
||||
"""Recycle operations wait for persisted context and keep confirmation protection."""
|
||||
import pytest
|
||||
from PySide6.QtCore import QTimer
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.models import TaskStatus
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
|
||||
@pytest.mark.parametrize('accept', [False, True])
|
||||
def test_deleted_task_has_confirmed_permanent_delete(qtbot, tmp_path, accept):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Recycle bin task')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
assert window.task_list.delete_button.text() == '删除'
|
||||
service.delete_task(task.task_id)
|
||||
window.task_list.filter.setCurrentText('已删除')
|
||||
window.open_task(task.task_id)
|
||||
assert window.task_list.delete_button.text() == '彻底删除'
|
||||
assert window.task_list.restore_button.isEnabled()
|
||||
observed = []
|
||||
|
||||
def choose():
|
||||
dialog = QApplication.activeModalWidget()
|
||||
assert isinstance(dialog, QMessageBox)
|
||||
assert 'Recycle bin task' in dialog.text()
|
||||
assert '诊断日志和执行证据保留' in dialog.text()
|
||||
assert '不再受队列执行锁' in dialog.text()
|
||||
assert dialog.defaultButton().text() == '取消'
|
||||
assert dialog.escapeButton().text() == '取消'
|
||||
observed.append(True)
|
||||
next(button for button in dialog.buttons() if button.text() == ('彻底删除' if accept else '取消')).click()
|
||||
|
||||
try:
|
||||
QTimer.singleShot(0, choose)
|
||||
window._delete_task()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=10000)
|
||||
assert observed == [True]
|
||||
if accept:
|
||||
assert window.task_list.list.count() == 0
|
||||
assert window._task_id is None
|
||||
assert not window.task_list.delete_button.isEnabled()
|
||||
with pytest.raises(TaskCenterError, match='unknown_task'):
|
||||
service.get_task(task.task_id)
|
||||
else:
|
||||
assert service.get_task(task.task_id).status is TaskStatus.DELETED
|
||||
assert window.task_list.list.count() == 1
|
||||
finally:
|
||||
window.close()
|
||||
store.close()
|
||||
@pytest.mark.parametrize('accept',[False,True])
|
||||
def test_deleted_task_has_confirmed_permanent_delete(ui,monkeypatch,accept):
|
||||
task=ui.tasks[0];w=ui.window
|
||||
ui.service.delete_task(task.task_id)
|
||||
w.task_list.recycle_button.setChecked(True);ui.open(task)
|
||||
assert w.task_list.delete_button.text()=='彻底删除'
|
||||
assert w.task_list.restore_button.isEnabled()
|
||||
observed=[]
|
||||
def choose(parent,title,text,buttons,default):
|
||||
observed.append((title,text,default))
|
||||
return QMessageBox.StandardButton.Yes if accept else QMessageBox.StandardButton.No
|
||||
monkeypatch.setattr(QMessageBox,'question',choose)
|
||||
w._delete_task();ui.settle()
|
||||
assert observed[0][2]==QMessageBox.StandardButton.No
|
||||
assert '工程文件和诊断证据保留' in observed[0][1]
|
||||
if accept:
|
||||
with pytest.raises(TaskCenterError,match='unknown_task'):
|
||||
ui.service.get_task(task.task_id)
|
||||
assert w.task_list.list.count()==0
|
||||
else:
|
||||
assert ui.service.get_task(task.task_id).status is TaskStatus.DELETED
|
||||
|
||||
|
||||
def test_restore_during_confirmation_cannot_be_permanently_deleted(qtbot, tmp_path):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_task('Concurrent restore')
|
||||
service.delete_task(task.task_id)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.task_list.filter.setCurrentText('已删除')
|
||||
|
||||
def restore_then_confirm():
|
||||
service.restore_task(task.task_id)
|
||||
dialog = QApplication.activeModalWidget()
|
||||
next(button for button in dialog.buttons() if button.text() == '彻底删除').click()
|
||||
|
||||
try:
|
||||
QTimer.singleShot(0, restore_then_confirm)
|
||||
window._delete_task()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=10000)
|
||||
assert service.get_task(task.task_id).status is TaskStatus.DRAFT
|
||||
assert '任务状态可能已变化' in window.run_panel.operator_band.text()
|
||||
finally:
|
||||
window.close()
|
||||
store.close()
|
||||
def test_restore_during_confirmation_prevents_permanent_delete(ui,monkeypatch):
|
||||
task=ui.tasks[0];w=ui.window
|
||||
ui.service.delete_task(task.task_id)
|
||||
w.task_list.recycle_button.setChecked(True);ui.open(task)
|
||||
def restore(*args):
|
||||
ui.service.restore_task(task.task_id)
|
||||
return QMessageBox.StandardButton.Yes
|
||||
monkeypatch.setattr(QMessageBox,'question',restore)
|
||||
w._delete_task();ui.settle()
|
||||
assert ui.service.get_task(task.task_id).status is TaskStatus.DRAFT
|
||||
assert '错误编号' in w.run_panel.operator_band.text()
|
||||
@@ -1,112 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
"""Public shell and recovery contracts for the current project-task UI."""
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QComboBox, QHeaderView, QListWidget, QPushButton, QSplitter, QTableWidget, QWidget
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.models import TaskStatus
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from PySide6.QtWidgets import QWidget,QMessageBox
|
||||
from dx_productivity.trial_task_center.version import VERSION
|
||||
|
||||
|
||||
def _service(tmp_path: Path) -> tuple[TaskCenterService, TaskStore]:
|
||||
store = TaskStore(tmp_path / "task-center.db")
|
||||
service = TaskCenterService(
|
||||
store,
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
)
|
||||
return service, store
|
||||
def test_shell_has_stable_automation_controls_and_current_navigation(ui):
|
||||
w=ui.window
|
||||
for name in ('taskList','taskSearch','taskSort','taskRecycleBin','newTaskButton',
|
||||
'mappingTable','batchPlanTabs','quickRunButton','executeProjectTasks',
|
||||
'boundProjectPath','exportBomTemplate','importBomPlan','toggleLogButton'):
|
||||
assert w.findChild(QWidget,name) is not None,name
|
||||
assert w.windowTitle()==f'DxDesigner 器件替换 · {VERSION}'
|
||||
assert not w.task_list.filter.isVisible()
|
||||
assert w.workspace_splitter.orientation()==Qt.Orientation.Horizontal
|
||||
assert not w.workspace_splitter.childrenCollapsible()
|
||||
assert w.detail_splitter.count()==2
|
||||
assert w.run_panel.log_dialog is None
|
||||
assert w._context.project.path==ui.store.list_projects(ui.tasks[0].task_id)[0].path
|
||||
|
||||
|
||||
def test_interrupted_task_offers_recovery_instead_of_repeat_replace(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service, store = _service(tmp_path)
|
||||
task = service.create_task("Interrupted")
|
||||
project = tmp_path / 'projects' / 'one.prj'
|
||||
project.parent.mkdir()
|
||||
project.touch()
|
||||
service.scan_projects(task.task_id, project.parent)
|
||||
service.set_project_selected(service.projects(task.task_id)[0].project_id, True)
|
||||
service.add_rule(task.task_id, 'OLD', 'NEW')
|
||||
handoff = service.prepare_quick_run(task.task_id)
|
||||
(handoff.command_path.parent / 'uncertain.flag').write_text('timeout')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
assert window.run_panel.recover_button.isVisible()
|
||||
assert window.run_panel.recover_button.isEnabled()
|
||||
assert not window.run_panel.quick_run_button.isEnabled()
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *args: QMessageBox.StandardButton.No)
|
||||
window._recover_quick_run()
|
||||
assert not window._workers
|
||||
assert (handoff.command_path.parent / 'uncertain.flag').exists()
|
||||
other = service.create_task('Other')
|
||||
assert not service.has_interrupted_quick_run(other.task_id)
|
||||
|
||||
|
||||
def test_shell_has_stable_automation_controls_and_task_filters(qtbot, tmp_path: Path) -> None:
|
||||
"""Removing task navigation controls would make archived work inaccessible."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service, store = _service(tmp_path)
|
||||
active = service.create_task("Active")
|
||||
completed = service.create_task("Completed")
|
||||
deleted = service.create_task("Deleted")
|
||||
store.set_task_status(completed.task_id, TaskStatus.READY)
|
||||
store.set_task_status(completed.task_id, TaskStatus.RUNNING)
|
||||
store.set_task_status(completed.task_id, TaskStatus.COMPLETED)
|
||||
service.delete_task(deleted.task_id)
|
||||
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
|
||||
assert window.minimumWidth() <= 900
|
||||
assert window.minimumHeight() <= 600
|
||||
task_filter = window.findChild(QComboBox, "taskFilter")
|
||||
task_list = window.findChild(QListWidget, "taskList")
|
||||
assert task_filter is not None
|
||||
assert task_list is not None
|
||||
assert {window.findChild(QWidget, name) is not None for name in (
|
||||
"newTaskButton", "editTaskButton", "deleteTaskButton", "restoreTaskButton", "directoryPath",
|
||||
"browseDirectoryButton", "scanProjectsButton", "projectTable", "selectAllProjectsButton",
|
||||
"clearProjectsButton", "mappingTable", "addMappingButton", "quickRunButton", "queueSummary",
|
||||
"executionStatus", "quickRunBusyIndicator", "logView",
|
||||
)} == {True}
|
||||
|
||||
assert [task_filter.itemText(index) for index in range(task_filter.count())] == ["进行中", "已完成", "已删除"]
|
||||
assert window.windowTitle() == "DxDesigner 器件批量替换任务中心 · 1.0.0"
|
||||
assert window.findChild(QWidget, "directoryPath").placeholderText() == "请选择 DxDesigner 工程所在目录"
|
||||
assert window.run_panel.operator_band.text() == "请扫描并勾选至少一个工程。"
|
||||
assert window.findChild(QPushButton, "newTaskButton").text() == "新建"
|
||||
assert window.findChild(QPushButton, "scanProjectsButton").text() == "扫描工程"
|
||||
assert window.findChild(QPushButton, "startTaskButton") is None
|
||||
assert window.findChild(QTableWidget, "projectTable").horizontalHeaderItem(0).text() == "选择"
|
||||
assert window.findChild(QTableWidget, "mappingTable").horizontalHeaderItem(0).text() == "旧物料编码"
|
||||
workspace_splitter = window.findChild(QSplitter, "workspaceSplitter")
|
||||
detail_splitter = window.findChild(QSplitter, "detailSplitter")
|
||||
assert workspace_splitter is not None and workspace_splitter.orientation() is Qt.Orientation.Horizontal
|
||||
assert detail_splitter is not None and detail_splitter.orientation() is Qt.Orientation.Vertical
|
||||
assert not workspace_splitter.childrenCollapsible()
|
||||
assert not detail_splitter.childrenCollapsible()
|
||||
assert detail_splitter.count() == 3
|
||||
project_header = window.findChild(QTableWidget, "projectTable").horizontalHeader()
|
||||
mapping_header = window.findChild(QTableWidget, "mappingTable").horizontalHeader()
|
||||
assert all(project_header.sectionResizeMode(section) is QHeaderView.ResizeMode.Interactive for section in range(1, 5))
|
||||
assert all(mapping_header.sectionResizeMode(section) is QHeaderView.ResizeMode.Interactive for section in range(4))
|
||||
assert task_list.currentItem().text() == "Active"
|
||||
assert window._task_id == active.task_id
|
||||
|
||||
task_filter.setCurrentText("已完成")
|
||||
assert [task_list.item(index).text() for index in range(task_list.count())] == ["Completed"]
|
||||
task_filter.setCurrentText("已删除")
|
||||
assert [task_list.item(index).text() for index in range(task_list.count())] == ["Deleted"]
|
||||
task_filter.setCurrentText("进行中")
|
||||
assert [task_list.item(index).text() for index in range(task_list.count())] == ["Active"]
|
||||
def test_interrupted_task_offers_recovery_and_declining_keeps_protection(ui,monkeypatch):
|
||||
w=ui.window;task=ui.tasks[0]
|
||||
handoff=ui.service.prepare_quick_run(task.task_id)
|
||||
lock=handoff.command_path.parent/'uncertain.flag';lock.write_text('timeout')
|
||||
ui.open(task)
|
||||
assert w.run_panel.recover_button.isVisible() and w.run_panel.recover_button.isEnabled()
|
||||
assert not w.run_panel.quick_run_button.isEnabled()
|
||||
monkeypatch.setattr(QMessageBox,'question',lambda *args:QMessageBox.StandardButton.No)
|
||||
w._recover_quick_run();ui.settle()
|
||||
assert lock.exists() and not ui.calls
|
||||
assert not ui.service.has_interrupted_quick_run(ui.tasks[1].task_id)
|
||||
@@ -1,769 +1,108 @@
|
||||
from __future__ import annotations
|
||||
"""Current confirmation, async ownership and editing contracts.
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
Removed multi-project-table/manual-capture controls are deliberately not recreated.
|
||||
Detailed stale-query/log/operation state checks live in tests/v1_1/test_ui_*.
|
||||
"""
|
||||
from threading import Event
|
||||
|
||||
import pytest
|
||||
from PySide6.QtCore import Qt, QTimer
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QAbstractItemView, QCheckBox, QComboBox, QPushButton, QTableWidget
|
||||
from shiboken6 import isValid
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from dx_productivity.trial_task_center.models import ProjectStatus, TaskStatus
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
|
||||
|
||||
def _service(tmp_path: Path) -> TaskCenterService:
|
||||
return TaskCenterService(
|
||||
TaskStore(tmp_path / "task-center.db"),
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
)
|
||||
|
||||
|
||||
def _service_and_store(tmp_path: Path) -> tuple[TaskCenterService, TaskStore]:
|
||||
store = TaskStore(tmp_path / "task-center.db")
|
||||
return (
|
||||
TaskCenterService(
|
||||
store,
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
),
|
||||
store,
|
||||
)
|
||||
|
||||
|
||||
def test_scan_selection_mapping_and_quick_run_gate_use_service_workers(qtbot, tmp_path: Path) -> None:
|
||||
"""A UI-thread scan or a permissive quick-run button could export unsafe task input."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
(root / "two.prj").touch()
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service, directory_picker=lambda: root)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
|
||||
scan = window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "scanProjectsButton")
|
||||
assert scan is not None
|
||||
QTest.mouseClick(window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "browseDirectoryButton"), Qt.MouseButton.LeftButton)
|
||||
QTest.mouseClick(scan, Qt.MouseButton.LeftButton)
|
||||
assert not scan.isEnabled()
|
||||
qtbot.waitUntil(lambda: scan.isEnabled(), timeout=5000)
|
||||
|
||||
projects = window.findChild(QTableWidget, "projectTable")
|
||||
quick_run = window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "quickRunButton")
|
||||
assert projects is not None and projects.rowCount() == 2
|
||||
assert quick_run is not None and not quick_run.isEnabled()
|
||||
QTest.mouseClick(window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "selectAllProjectsButton"), Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: all(project.selected for project in service.projects(task.task_id)), timeout=2000)
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=2000)
|
||||
assert not quick_run.isEnabled()
|
||||
|
||||
window.add_mapping("OLD-1", "NEW-1")
|
||||
qtbot.waitUntil(lambda: quick_run.isEnabled(), timeout=2000)
|
||||
mappings = window.findChild(QTableWidget, "mappingTable")
|
||||
assert mappings is not None and mappings.rowCount() == 1
|
||||
clear = window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "clearProjectsButton")
|
||||
qtbot.waitUntil(clear.isEnabled, timeout=2000)
|
||||
QTest.mouseClick(clear, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: not quick_run.isEnabled(), timeout=2000)
|
||||
|
||||
|
||||
def test_changing_directory_hides_and_replaces_previous_scan(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
first_root = tmp_path / "first"
|
||||
second_root = tmp_path / "second"
|
||||
first_root.mkdir()
|
||||
second_root.mkdir()
|
||||
(first_root / "old.prj").touch()
|
||||
(second_root / "new.prj").touch()
|
||||
choices = iter((first_root, second_root))
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service, directory_picker=lambda: next(choices))
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
|
||||
QTest.mouseClick(window.browse_directory_button, Qt.MouseButton.LeftButton)
|
||||
QTest.mouseClick(window.scan_projects_button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: window.project_table.rowCount() == 1, timeout=5000)
|
||||
assert service.projects(task.task_id)[0].path.name == "old.prj"
|
||||
|
||||
QTest.mouseClick(window.browse_directory_button, Qt.MouseButton.LeftButton)
|
||||
assert window.project_table.rowCount() == 0
|
||||
assert window.run_panel.execution_status.text() == "等待扫描"
|
||||
QTest.mouseClick(window.scan_projects_button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(
|
||||
lambda: window.project_table.rowCount() == 1
|
||||
and service.projects(task.task_id)[0].path.name == "new.prj",
|
||||
timeout=5000,
|
||||
)
|
||||
assert [project.path.name for project in service.projects(task.task_id)] == ["new.prj"]
|
||||
|
||||
|
||||
def test_quick_run_button_confirms_and_executes_replacement_without_showing_a_script_path(qtbot, tmp_path: Path) -> None:
|
||||
"""The primary action must complete replacement instead of handing a script to the operator."""
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
import subprocess
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service = TaskCenterService(
|
||||
TaskStore(tmp_path / "task-center.db"),
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
quick_run_preparer=QuickRunPreparer(
|
||||
tmp_path / "storage",
|
||||
process_runner=lambda command, timeout: _write_completed_status(command, tmp_path / "storage", timeout),
|
||||
cscript_resolver=lambda: Path("C:/Windows/SysWOW64/cscript.exe"),
|
||||
sheet_discoverer=lambda project: (("Main", "1"),),
|
||||
),
|
||||
)
|
||||
task = service.create_task("Quick")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, "OLD-1", "NEW-1")
|
||||
window = TrialTaskCenterWindow(service, quick_run_confirmer=lambda *_args: True)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
|
||||
button = window.findChild(QPushButton, "quickRunButton")
|
||||
assert button is not None and button.isEnabled()
|
||||
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
|
||||
assert "成功 1,失败 0,未命中 0" in window.run_panel.operator_band.text()
|
||||
assert button.text() == "当前队列已完成"
|
||||
assert not button.isEnabled()
|
||||
assert "QuickPartReplace.vbs" not in window.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def _write_completed_status(command: tuple[str, ...], data_root: Path, timeout: int):
|
||||
import subprocess
|
||||
|
||||
assert timeout == 150
|
||||
command_path = data_root / "quick-run" / "command.tsv"
|
||||
command_lines = command_path.read_text(encoding="utf-8").splitlines()
|
||||
job_id = command_lines[1].split("\t")[command_lines[0].split("\t").index("job_id")]
|
||||
(data_root / "quick-run" / "status.tsv").write_text(
|
||||
"job_id\tstate\tcode\tmessage\n"
|
||||
f"{job_id}\tawaiting_native_replace\t\tSelected current-sheet matches.\n"
|
||||
f"{job_id}\tsaved_ok\tbatch_closed\tAutomatic replacement verified and saved.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return subprocess.CompletedProcess(command, 0, "", "")
|
||||
|
||||
|
||||
def test_quick_run_confirmation_runs_the_full_replacement_once(qtbot, tmp_path: Path) -> None:
|
||||
"""One confirmation must cover native replacement, restoration, and verification."""
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service = TaskCenterService(
|
||||
TaskStore(tmp_path / "task-center.db"),
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
quick_run_preparer=QuickRunPreparer(
|
||||
tmp_path / "storage",
|
||||
process_runner=lambda command, timeout: _write_completed_status(command, tmp_path / "storage", timeout),
|
||||
cscript_resolver=lambda: Path("C:/Windows/SysWOW64/cscript.exe"),
|
||||
sheet_discoverer=lambda project: (("Main", "1"),),
|
||||
),
|
||||
)
|
||||
task = service.create_task("Quick")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, "OLD-1", "NEW-1")
|
||||
confirmations: list[tuple[object, ...]] = []
|
||||
|
||||
def confirm(*args: object) -> bool:
|
||||
confirmations.append(args)
|
||||
return True
|
||||
|
||||
window = TrialTaskCenterWindow(service, quick_run_confirmer=confirm)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
button = window.findChild(QPushButton, "quickRunButton")
|
||||
assert button is not None and button.isEnabled()
|
||||
|
||||
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
|
||||
assert confirmations == [("selection", 1, 1)]
|
||||
assert window._quick_run_phase == "complete"
|
||||
assert button.text() == "当前队列已完成"
|
||||
assert not button.isEnabled()
|
||||
|
||||
|
||||
def test_quick_run_cancellation_does_not_execute_replacement(qtbot, tmp_path: Path) -> None:
|
||||
"""Cancelling the confirmation must stop before service execution is queued."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Quick")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, "OLD-1", "NEW-1")
|
||||
confirmations: list[tuple[object, ...]] = []
|
||||
executions: list[str] = []
|
||||
service.execute_quick_run_queue = lambda task_id, **kwargs: executions.append(task_id)
|
||||
|
||||
def cancel(*args: object) -> bool:
|
||||
confirmations.append(args)
|
||||
return False
|
||||
|
||||
window = TrialTaskCenterWindow(service, quick_run_confirmer=cancel)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
button = window.findChild(QPushButton, "quickRunButton")
|
||||
assert button is not None and button.isEnabled()
|
||||
|
||||
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
|
||||
|
||||
assert confirmations == [("selection", 1, 1)]
|
||||
assert executions == []
|
||||
assert not window._workers
|
||||
|
||||
|
||||
def test_mapping_enabled_checkbox_updates_the_rule_and_execution_gate(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Quick")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(task.task_id, "OLD-1", "NEW-1")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
|
||||
enabled_cell = window.mapping_table.cellWidget(0, 4)
|
||||
enabled_check = enabled_cell.findChild(QCheckBox) if enabled_cell is not None else None
|
||||
assert enabled_check is not None and enabled_check.isChecked()
|
||||
QTest.mouseClick(enabled_check, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: not service.rules(task.task_id)[0].enabled, timeout=2000)
|
||||
|
||||
assert not window.run_panel.quick_run_button.isEnabled()
|
||||
|
||||
|
||||
def test_error_feedback_keeps_specific_reason_and_treats_completion_as_normal(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Quick")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
|
||||
window._show_error(TaskCenterError("quick_run_execution", "target library row NEW-1 was not found"))
|
||||
assert "target library row NEW-1 was not found" in window.run_panel.operator_band.text()
|
||||
assert "不能假定图页未修改" in window.run_panel.operator_band.text()
|
||||
|
||||
window._show_error(TaskCenterError("quick_run_uncertain", "worker returned an uncorrelated status"))
|
||||
assert "无法确认本次替换结果" in window.run_panel.operator_band.text()
|
||||
assert "超时" not in window.run_panel.operator_band.text()
|
||||
|
||||
window._show_error(TaskCenterError("quick_run_complete", "all quick-run items are complete"))
|
||||
assert "无需重复执行" in window.run_panel.operator_band.text()
|
||||
assert "操作失败" not in window.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def test_opening_a_task_with_a_completed_quick_run_restores_the_completed_phase(qtbot, tmp_path: Path) -> None:
|
||||
"""A task switch must preserve the durable completed queue state."""
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service = TaskCenterService(
|
||||
TaskStore(tmp_path / "task-center.db"),
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
quick_run_preparer=QuickRunPreparer(
|
||||
tmp_path / "storage",
|
||||
process_runner=lambda command, timeout: _write_completed_status(command, tmp_path / "storage", timeout),
|
||||
cscript_resolver=lambda: Path("C:/Windows/SysWOW64/cscript.exe"),
|
||||
sheet_discoverer=lambda project: (("Main", "1"),),
|
||||
),
|
||||
)
|
||||
first = service.create_task("First")
|
||||
project = service.scan_projects(first.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(first.task_id, "OLD-1", "NEW-1")
|
||||
second = service.create_task("Second")
|
||||
confirmations: list[tuple[object, ...]] = []
|
||||
window = TrialTaskCenterWindow(
|
||||
service,
|
||||
quick_run_confirmer=lambda *args: confirmations.append(args) or True,
|
||||
)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(first.task_id)
|
||||
button = window.findChild(QPushButton, "quickRunButton")
|
||||
assert button is not None and button.isEnabled()
|
||||
|
||||
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
window.open_task(second.task_id)
|
||||
window.open_task(first.task_id)
|
||||
|
||||
assert window._quick_run_phase == "complete"
|
||||
assert button.text() == "当前队列已完成"
|
||||
assert not button.isEnabled()
|
||||
assert confirmations == [("selection", 1, 1)]
|
||||
|
||||
|
||||
def test_returning_to_a_task_recovers_completion_after_its_late_worker_result_is_discarded(qtbot, tmp_path: Path) -> None:
|
||||
"""The status queue, rather than a discarded UI callback, determines task completion."""
|
||||
from dx_productivity.trial_task_center.quick_run import QuickRunPreparer
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
import subprocess
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
worker_started = Event()
|
||||
allow_completion = Event()
|
||||
|
||||
def delayed_completed_status(command: tuple[str, ...], timeout: int):
|
||||
assert timeout == 150
|
||||
worker_started.set()
|
||||
assert allow_completion.wait(3)
|
||||
return _write_completed_status(command, tmp_path / "storage", timeout)
|
||||
|
||||
service = TaskCenterService(
|
||||
TaskStore(tmp_path / "task-center.db"),
|
||||
configure_logging(tmp_path / "storage"),
|
||||
path_opener=lambda _path: None,
|
||||
clock=lambda: datetime(2026, 9, 4, tzinfo=timezone.utc),
|
||||
quick_run_preparer=QuickRunPreparer(
|
||||
tmp_path / "storage",
|
||||
process_runner=delayed_completed_status,
|
||||
cscript_resolver=lambda: Path("C:/Windows/SysWOW64/cscript.exe"),
|
||||
sheet_discoverer=lambda project: (("Main", "1"),),
|
||||
),
|
||||
)
|
||||
first = service.create_task("First")
|
||||
project = service.scan_projects(first.task_id, root)[0]
|
||||
service.set_project_selected(project.project_id, True)
|
||||
service.add_rule(first.task_id, "OLD-1", "NEW-1")
|
||||
second = service.create_task("Second")
|
||||
window = TrialTaskCenterWindow(service, quick_run_confirmer=lambda *_args: True)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(first.task_id)
|
||||
button = window.findChild(QPushButton, "quickRunButton")
|
||||
assert button is not None and button.isEnabled()
|
||||
|
||||
QTest.mouseClick(button, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(worker_started.is_set, timeout=3000)
|
||||
window.open_task(second.task_id)
|
||||
allow_completion.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
window.open_task(first.task_id)
|
||||
|
||||
assert window._quick_run_phase == "complete"
|
||||
assert button.text() == "当前队列已完成"
|
||||
assert not button.isEnabled()
|
||||
|
||||
|
||||
def test_project_filter_read_only_tables_and_selected_failed_project_action(qtbot, tmp_path: Path) -> None:
|
||||
"""Editing a cell or acting on the active project would hide a failed selected row."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "failed.prj").touch()
|
||||
(root / "done.prj").touch()
|
||||
service, store = _service_and_store(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
projects = service.scan_projects(task.task_id, root)
|
||||
by_name = {project.path.name: project for project in projects}
|
||||
failed = by_name["failed.prj"]
|
||||
done = by_name["done.prj"]
|
||||
store.set_task_status(task.task_id, TaskStatus.RUNNING)
|
||||
for status in (ProjectStatus.CAPTURING_BEFORE, ProjectStatus.AWAITING_OPERATOR, ProjectStatus.CAPTURING_AFTER, ProjectStatus.VERIFYING):
|
||||
store.set_project_status(done.project_id, status)
|
||||
store.set_project_status(done.project_id, ProjectStatus.COMPLETED)
|
||||
store.set_project_status(failed.project_id, ProjectStatus.CAPTURING_BEFORE)
|
||||
store.set_project_status(failed.project_id, ProjectStatus.FAILED)
|
||||
store.set_task_status(task.task_id, TaskStatus.FAILED)
|
||||
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
project_filter = window.findChild(QComboBox, "projectFilter")
|
||||
assert project_filter is not None
|
||||
assert window.project_table.editTriggers() == QAbstractItemView.EditTrigger.NoEditTriggers
|
||||
assert window.mapping_table.editTriggers() == QAbstractItemView.EditTrigger.NoEditTriggers
|
||||
assert [project_filter.itemText(index) for index in range(project_filter.count())] == ["全部", "待处理", "已完成"]
|
||||
project_filter.setCurrentText("已完成")
|
||||
assert window.project_table.rowCount() == 1
|
||||
project_filter.setCurrentText("待处理")
|
||||
assert window.project_table.rowCount() == 1
|
||||
project_filter.setCurrentText("全部")
|
||||
assert window.project_table.rowCount() == 2
|
||||
assert window.project_table.item(0, 3).text() in {"失败", "已完成"}
|
||||
|
||||
failed_row = next(
|
||||
row for row in range(window.project_table.rowCount())
|
||||
if window.project_table.item(row, 1).data(Qt.ItemDataRole.UserRole) == failed.project_id
|
||||
)
|
||||
window.project_table.selectRow(failed_row)
|
||||
skip = window.findChild(QPushButton, "skipProjectButton")
|
||||
assert skip is not None and skip.isEnabled()
|
||||
QTest.mouseClick(skip, Qt.MouseButton.LeftButton)
|
||||
qtbot.waitUntil(lambda: next(project for project in service.projects(task.task_id) if project.project_id == failed.project_id).status is ProjectStatus.SKIPPED, timeout=3000)
|
||||
|
||||
|
||||
def test_worker_completion_is_ignored_after_opening_a_different_task_without_exposing_probe_controls(qtbot, tmp_path: Path) -> None:
|
||||
"""A late worker completion must not paint task A's result into task B's workspace."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
first = service.create_task("First")
|
||||
second = service.create_task("Second")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(first.task_id)
|
||||
called: list[str] = []
|
||||
gate = Event()
|
||||
window._run_async(lambda: (gate.wait(), "late")[1], lambda value: called.append(value), expected_task_id=first.task_id)
|
||||
window.open_task(second.task_id)
|
||||
QTimer.singleShot(0, gate.set)
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert called == []
|
||||
assert window.findChild(__import__("PySide6.QtWidgets", fromlist=["QLineEdit"]).QLineEdit, "probePath") is None
|
||||
assert window.findChild(__import__("PySide6.QtWidgets", fromlist=["QPushButton"]).QPushButton, "chooseProbeButton") is None
|
||||
|
||||
|
||||
def test_worker_completion_does_not_touch_widgets_after_window_destruction(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Closing")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
entered = Event()
|
||||
release = Event()
|
||||
button = window.scan_projects_button
|
||||
|
||||
window._run_async(
|
||||
lambda: (entered.set(), release.wait())[1],
|
||||
lambda _result: None,
|
||||
button,
|
||||
expected_task_id=task.task_id,
|
||||
)
|
||||
qtbot.waitUntil(entered.is_set, timeout=3000)
|
||||
window.deleteLater()
|
||||
qtbot.waitUntil(lambda: not isValid(window), timeout=3000)
|
||||
assert not isValid(button)
|
||||
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
|
||||
|
||||
def test_refresh_does_not_replace_open_task_with_previous_list_selection(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
first = service.create_task("First")
|
||||
second = service.create_task("Second")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window._select_task_item(first.task_id)
|
||||
window.open_task(second.task_id)
|
||||
window._refresh_task_list()
|
||||
assert window._task_id == second.task_id
|
||||
assert window.task_list.current_task_id() == second.task_id
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fails", [False, True])
|
||||
def test_background_queue_completion_refreshes_current_task_without_losing_failure(qtbot, tmp_path: Path, monkeypatch, fails) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service, store = _service_and_store(tmp_path)
|
||||
first = service.create_task("First")
|
||||
second = service.create_task("Second")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(first.task_id)
|
||||
gate = Event()
|
||||
applied = []
|
||||
diagnostics = []
|
||||
show_error = window._show_error
|
||||
|
||||
def capture_error(error, **context):
|
||||
diagnostics.append((error, context))
|
||||
show_error(error, **context)
|
||||
|
||||
monkeypatch.setattr(window, "_show_error", capture_error)
|
||||
|
||||
def run_queue():
|
||||
gate.wait(5)
|
||||
store.set_task_status(first.task_id, TaskStatus.RUNNING)
|
||||
if fails:
|
||||
store.set_task_status(first.task_id, TaskStatus.PAUSED)
|
||||
raise TaskCenterError("quick_run_execution", "background diagnostic")
|
||||
store.set_task_status(first.task_id, TaskStatus.COMPLETED)
|
||||
return "first result"
|
||||
|
||||
window._run_async(run_queue, applied.append, window.run_panel.quick_run_button, expected_task_id=first.task_id)
|
||||
window.open_task(second.task_id)
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QCloseEvent
|
||||
|
||||
|
||||
@pytest.mark.parametrize('accept',[False,True])
|
||||
def test_current_task_executes_only_after_confirmation_and_no_match_is_completed(ui,accept):
|
||||
w=ui.window;confirmations=[]
|
||||
w._quick_run_confirmer=lambda *args:confirmations.append(args) or accept
|
||||
assert w.run_panel.quick_run_button.isEnabled()
|
||||
w._prepare_quick_run();ui.settle()
|
||||
assert confirmations==[('current',1,1)]
|
||||
assert len(ui.calls)==int(accept), w.run_panel.operator_band.text()
|
||||
assert ui.service.quick_run_progress(ui.tasks[0].task_id).queue_complete is accept
|
||||
if accept:
|
||||
assert ui.service.quick_run_progress(ui.tasks[0].task_id).no_match_items==1
|
||||
assert w.run_panel.new_round_button.isEnabled()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('value',[False,True])
|
||||
def test_changed_value_policy_stops_stale_confirmation_before_worker(ui,value):
|
||||
w=ui.window;task=ui.tasks[0]
|
||||
if value:
|
||||
ui.service.set_copy_part_number_to_value(task.task_id,True);ui.open(task)
|
||||
ui.service.set_copy_part_number_to_value(task.task_id,not value)
|
||||
w._quick_run_confirmer=lambda *args:True
|
||||
w._prepare_quick_run();ui.settle()
|
||||
assert not ui.calls
|
||||
assert '错误编号' in w.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def test_mapping_enable_uses_model_and_persists_without_row_widgets(ui):
|
||||
w=ui.window;model=w.mapping_table.model();index=model.index(0,4)
|
||||
assert model.data(index,Qt.ItemDataRole.CheckStateRole)==Qt.CheckState.Checked
|
||||
assert model.setData(index,Qt.CheckState.Unchecked,Qt.ItemDataRole.CheckStateRole)
|
||||
ui.settle()
|
||||
assert not ui.service.rules(ui.tasks[0].task_id)[0].enabled
|
||||
assert not w.run_panel.quick_run_button.isEnabled()
|
||||
|
||||
|
||||
def test_regular_mutation_locks_navigation_until_completion(ui,qtbot):
|
||||
w=ui.window;started,release=Event(),Event();received=[]
|
||||
def work():
|
||||
started.set();assert release.wait(5);return 'late'
|
||||
try:
|
||||
assert not window.task_list.delete_button.isEnabled()
|
||||
finally:
|
||||
gate.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=10000)
|
||||
assert window._task_id == second.task_id
|
||||
assert window.task_list.delete_button.isEnabled()
|
||||
assert applied == []
|
||||
listed = [window.task_list.list.item(index).data(Qt.ItemDataRole.UserRole) for index in range(window.task_list.list.count())]
|
||||
assert (first.task_id in listed) is fails
|
||||
if fails:
|
||||
assert len(diagnostics) == 1
|
||||
assert diagnostics[0][0].message == "background diagnostic"
|
||||
assert diagnostics[0][1]["task_id"] == first.task_id
|
||||
assert "background diagnostic" not in window.run_panel.operator_band.text()
|
||||
assert window._last_error_task_id == first.task_id
|
||||
assert window._last_error_project_id is None
|
||||
w._run_async(work,received.append,expected_task_id=ui.tasks[0].task_id)
|
||||
qtbot.waitUntil(started.is_set)
|
||||
w.open_task(ui.tasks[1].task_id)
|
||||
assert w._task_id==ui.tasks[0].task_id
|
||||
assert not w.task_list.list.isEnabled()
|
||||
finally:release.set()
|
||||
ui.settle()
|
||||
assert received==['late']
|
||||
ui.open(ui.tasks[1])
|
||||
|
||||
|
||||
def test_newer_worker_keeps_shared_button_locked_until_its_own_completion(qtbot, tmp_path: Path) -> None:
|
||||
"""An older completion must not re-enable a button owned by a newer dispatch."""
|
||||
def test_close_during_execution_requests_boundary_pause_and_waits(ui,qtbot):
|
||||
w=ui.window;started,release=Event(),Event()
|
||||
def work():
|
||||
started.set();assert release.wait(5)
|
||||
w._begin_run(ui.tasks[0].task_id)
|
||||
try:
|
||||
w._run_async(work,lambda _:w._finish_run(),expected_task_id=ui.tasks[0].task_id)
|
||||
qtbot.waitUntil(started.is_set)
|
||||
event=QCloseEvent();w.closeEvent(event)
|
||||
assert not event.isAccepted() and w._batch_stop.is_set()
|
||||
assert not w._closed
|
||||
finally:release.set()
|
||||
ui.settle()
|
||||
|
||||
|
||||
def test_metadata_refresh_keeps_current_task_selection(ui):
|
||||
w=ui.window;ui.open(ui.tasks[1])
|
||||
w._metadata_changed(None);ui.settle()
|
||||
assert w._task_id==ui.tasks[1].task_id
|
||||
assert w._context.task.task_id==ui.tasks[1].task_id
|
||||
|
||||
|
||||
@pytest.mark.parametrize('worker_error', [False, True])
|
||||
def test_destroyed_window_cannot_receive_late_worker_ui_callbacks(ui,qtbot,worker_error):
|
||||
from PySide6.QtCore import QCoreApplication,QEvent,QThreadPool
|
||||
from shiboken6 import isValid
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
first_gate, second_gate = Event(), Event()
|
||||
applied: list[str] = []
|
||||
button = window.scan_projects_button
|
||||
window._run_async(lambda: (first_gate.wait(), "old")[1], applied.append, button, expected_task_id=task.task_id)
|
||||
window._run_async(lambda: (second_gate.wait(), "new")[1], applied.append, button, expected_task_id=task.task_id)
|
||||
first_gate.set()
|
||||
qtbot.waitUntil(lambda: len(window._workers) == 1, timeout=3000)
|
||||
assert not button.isEnabled()
|
||||
second_gate.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert button.isEnabled()
|
||||
assert applied == ["new"]
|
||||
|
||||
|
||||
def test_selection_commands_lock_each_other_and_paused_capture_after_uses_selected_project(qtbot, tmp_path: Path, monkeypatch) -> None:
|
||||
"""Batch selection cannot overlap, and paused verification still targets the selected awaiting project."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "one.prj").touch()
|
||||
service, store = _service_and_store(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
entered, release = Event(), Event()
|
||||
original_select_all = service.select_all_projects
|
||||
|
||||
def slow_select_all(task_id: str):
|
||||
entered.set()
|
||||
release.wait()
|
||||
return original_select_all(task_id)
|
||||
|
||||
monkeypatch.setattr(service, "select_all_projects", slow_select_all)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
window._select_all_projects()
|
||||
qtbot.waitUntil(entered.is_set, timeout=3000)
|
||||
assert not window.select_all_projects_button.isEnabled()
|
||||
assert not window.clear_projects_button.isEnabled()
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
|
||||
store.set_task_status(task.task_id, TaskStatus.RUNNING)
|
||||
store.set_project_status(project.project_id, ProjectStatus.CAPTURING_BEFORE)
|
||||
store.set_project_status(project.project_id, ProjectStatus.AWAITING_OPERATOR)
|
||||
store.set_task_status(task.task_id, TaskStatus.PAUSED)
|
||||
window.open_task(task.task_id)
|
||||
window.project_table.selectRow(0)
|
||||
assert window.run_panel.capture_after_button.isEnabled()
|
||||
|
||||
|
||||
def test_project_checkbox_keeps_scroll_position_after_async_reload(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Scrollable")
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
paths = tuple(root / f"project-{index:03d}.prj" for index in range(80))
|
||||
for path in paths:
|
||||
path.write_text(
|
||||
'SECTION DesignInfo\nKEY FrontEndSnapshot "DxD"\nENDSECTION\n'
|
||||
'SECTION iCDB\nKEY iCDBDir ".\\database"\nENDSECTION\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
service.scan_projects(task.task_id, root)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.resize(900, 600)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
scroll_bar = window.project_table.verticalScrollBar()
|
||||
qtbot.waitUntil(lambda: scroll_bar.maximum() > 0, timeout=3000)
|
||||
target = max(1, scroll_bar.maximum() // 2)
|
||||
scroll_bar.setValue(target)
|
||||
visible_row = window.project_table.rowAt(window.project_table.viewport().height() // 2)
|
||||
checkbox = window.project_table.cellWidget(visible_row, 0)
|
||||
|
||||
checkbox.setChecked(not checkbox.isChecked())
|
||||
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert scroll_bar.value() == target
|
||||
|
||||
|
||||
def test_empty_project_scan_explains_that_non_schematic_projects_are_ignored(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Schematic only")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
|
||||
window._project_scan_finished(())
|
||||
|
||||
assert "未发现可用的 DxDesigner 原理图工程" in window.run_panel.operator_band.text()
|
||||
assert "PCB 工程和其他 .prj 文件已忽略" in window.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def test_failure_diagnostics_keep_a_stable_id_without_evidence_button(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
store = TaskStore(tmp_path / "task-center.db")
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / "storage"))
|
||||
root = tmp_path / "projects"
|
||||
root.mkdir()
|
||||
(root / "failed.prj").touch()
|
||||
task = service.create_task("Trial")
|
||||
project = service.scan_projects(task.task_id, root)[0]
|
||||
store.set_task_status(task.task_id, TaskStatus.RUNNING)
|
||||
store.set_project_status(project.project_id, ProjectStatus.CAPTURING_BEFORE)
|
||||
store.set_project_status(project.project_id, ProjectStatus.FAILED)
|
||||
store.set_task_status(task.task_id, TaskStatus.FAILED)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
window.project_table.selectRow(0)
|
||||
|
||||
window._show_error(RuntimeError("boom"))
|
||||
assert "错误编号:DXT-" in window.run_panel.operator_band.text()
|
||||
assert not hasattr(window.run_panel, "open_evidence_button")
|
||||
|
||||
|
||||
def test_workers_on_different_buttons_complete_without_cancelling_each_other(qtbot, tmp_path: Path) -> None:
|
||||
"""A newer operation in another button domain must not discard the first result."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
first_gate, second_gate = Event(), Event()
|
||||
applied: list[str] = []
|
||||
window._run_async(lambda: (first_gate.wait(), "scan")[1], applied.append, window.scan_projects_button, expected_task_id=task.task_id)
|
||||
window._run_async(lambda: (second_gate.wait(), "browse")[1], applied.append, window.browse_directory_button, expected_task_id=task.task_id)
|
||||
first_gate.set()
|
||||
qtbot.waitUntil(lambda: "scan" in applied, timeout=3000)
|
||||
assert window.scan_projects_button.isEnabled()
|
||||
assert not window.browse_directory_button.isEnabled()
|
||||
second_gate.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert applied == ["scan", "browse"]
|
||||
assert window.browse_directory_button.isEnabled()
|
||||
|
||||
|
||||
def test_window_refuses_to_close_while_regular_worker_is_running(qtbot, tmp_path: Path) -> None:
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(task.task_id)
|
||||
entered = Event()
|
||||
release = Event()
|
||||
window._run_async(lambda: (entered.set(), release.wait())[1], lambda _result: None)
|
||||
qtbot.waitUntil(entered.is_set, timeout=3000)
|
||||
|
||||
assert window.close() is False
|
||||
assert window.isVisible()
|
||||
assert "后台操作尚未结束" in window.run_panel.operator_band.text()
|
||||
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert window.close() is True
|
||||
|
||||
|
||||
def test_selection_domain_and_unrelated_worker_complete_independently(qtbot, tmp_path: Path) -> None:
|
||||
"""Selection ownership must not be stranded by an unrelated worker generation."""
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
service = _service(tmp_path)
|
||||
task = service.create_task("Trial")
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
selection_gate, scan_gate = Event(), Event()
|
||||
applied: list[str] = []
|
||||
window._run_async(lambda: (selection_gate.wait(), "selection")[1], applied.append, expected_task_id=task.task_id, selection_operation=True)
|
||||
window._run_async(lambda: (scan_gate.wait(), "scan")[1], applied.append, window.scan_projects_button, expected_task_id=task.task_id)
|
||||
selection_gate.set()
|
||||
qtbot.waitUntil(lambda: "selection" in applied, timeout=3000)
|
||||
assert window.select_all_projects_button.isEnabled()
|
||||
assert not window.scan_projects_button.isEnabled()
|
||||
scan_gate.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
assert applied == ["selection", "scan"]
|
||||
assert window.scan_projects_button.isEnabled()
|
||||
window=TrialTaskCenterWindow(ui.service)
|
||||
qtbot.waitUntil(lambda:not window._task_query.busy and not window._context_query.busy)
|
||||
started,release=Event(),Event();callbacks=[]
|
||||
def work():
|
||||
started.set();assert release.wait(5)
|
||||
try:
|
||||
def operation():
|
||||
work()
|
||||
if worker_error:
|
||||
raise RuntimeError('late worker failure')
|
||||
window._run_async(operation,lambda _:callbacks.append('late'))
|
||||
qtbot.waitUntil(started.is_set)
|
||||
window.deleteLater()
|
||||
QCoreApplication.sendPostedEvents(None,QEvent.Type.DeferredDelete)
|
||||
assert not isValid(window)
|
||||
finally:release.set()
|
||||
assert QThreadPool.globalInstance().waitForDone(5000)
|
||||
qtbot.wait(30)
|
||||
assert not callbacks
|
||||
@@ -1,115 +1,43 @@
|
||||
from pathlib import Path
|
||||
from threading import Event
|
||||
|
||||
from PySide6.QtCore import QPoint, Qt
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QCheckBox, QToolButton
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow, _MappingDialog
|
||||
"""Task-local Value policy, optional Cells and current layout persistence."""
|
||||
from PySide6.QtWidgets import QToolButton
|
||||
from dx_productivity.trial_task_center.ui.dialogs import _MappingDialog
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
|
||||
def make_window(qtbot, tmp_path):
|
||||
service = TaskCenterService(TaskStore(tmp_path / 'tasks.db'), configure_logging(tmp_path / 'data'))
|
||||
first = service.create_task('First')
|
||||
second = service.create_task('Second')
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.show()
|
||||
window.open_task(first.task_id)
|
||||
return window, service, first, second
|
||||
def test_value_checkbox_is_task_scoped_and_defaults_off(ui,qtbot):
|
||||
w=ui.window;checkbox=w.run_panel.copy_value_check
|
||||
assert 'Part Label' in checkbox.text() and not checkbox.isChecked()
|
||||
checkbox.click();ui.settle()
|
||||
assert ui.service.get_task(ui.tasks[0].task_id).copy_part_number_to_value
|
||||
ui.open(ui.tasks[1]);assert not checkbox.isChecked()
|
||||
ui.open(ui.tasks[0]);assert checkbox.isChecked()
|
||||
|
||||
|
||||
def test_value_checkbox_is_task_scoped_and_defaults_off(qtbot, tmp_path):
|
||||
window, service, first, second = make_window(qtbot, tmp_path)
|
||||
checkbox = window.findChild(QCheckBox, 'copyPartNumberToValue')
|
||||
assert checkbox is not None
|
||||
assert checkbox.text() == '替换后将 Part Label 写入 Value'
|
||||
assert not checkbox.isChecked()
|
||||
assert checkbox.isEnabled()
|
||||
QTest.mouseClick(checkbox, Qt.MouseButton.LeftButton, pos=QPoint(8, checkbox.height() // 2))
|
||||
qtbot.waitUntil(lambda: service.get_task(first.task_id).copy_part_number_to_value)
|
||||
qtbot.waitUntil(lambda: not window._workers)
|
||||
window.open_task(second.task_id)
|
||||
assert not checkbox.isChecked()
|
||||
window.open_task(first.task_id)
|
||||
assert checkbox.isChecked()
|
||||
|
||||
|
||||
def test_mapping_dialog_exposes_custom_value_and_nc_controls(qtbot):
|
||||
dialog = _MappingDialog(None, "OLD", "NEW", True, True, "22uF", False)
|
||||
def test_mapping_dialog_exposes_custom_value_nc_and_optional_cell(qtbot):
|
||||
dialog=_MappingDialog(None,'OLD','NEW',True,True,'22uF',False)
|
||||
qtbot.addWidget(dialog)
|
||||
assert dialog.custom_value_check.isChecked()
|
||||
assert dialog.values()==('OLD','NEW',True,True,'22uF',False)
|
||||
assert dialog.custom_value_edit.isEnabled()
|
||||
assert dialog.custom_value_edit.text() == "22uF"
|
||||
assert not dialog.sync_nc_check.isChecked()
|
||||
assert dialog.values() == ("OLD", "NEW", True, True, "22uF", False)
|
||||
assert dialog.target_cell=='' and '可选' in dialog.cell_combo.itemText(0)
|
||||
|
||||
|
||||
def test_small_window_has_useful_drag_range_and_collapsible_log(qtbot, tmp_path):
|
||||
window, _, _, _ = make_window(qtbot, tmp_path)
|
||||
window.resize(900, 600)
|
||||
qtbot.wait(20)
|
||||
splitter = window.detail_splitter
|
||||
lower, upper = splitter.getRange(1)
|
||||
assert upper - lower >= 90
|
||||
splitter.setSizes((230, 140, 190))
|
||||
before = splitter.sizes()[0]
|
||||
handle = splitter.handle(1)
|
||||
center = handle.rect().center()
|
||||
QTest.mousePress(handle, Qt.MouseButton.LeftButton, pos=center)
|
||||
QTest.mouseMove(handle, center + QPoint(0, 60), delay=20)
|
||||
QTest.mouseRelease(handle, Qt.MouseButton.LeftButton, pos=center + QPoint(0, 60))
|
||||
assert splitter.sizes()[0] - before >= 40
|
||||
toggle = window.findChild(QToolButton, 'toggleLogButton')
|
||||
assert toggle is not None and not window.run_panel.log_view.isVisible()
|
||||
QTest.mouseClick(toggle, Qt.MouseButton.LeftButton)
|
||||
assert window.run_panel.log_view.isVisible()
|
||||
def test_small_window_keeps_splitters_and_opens_log_in_disposable_window(ui,qtbot):
|
||||
w=ui.window;w.resize(980,700);qtbot.wait(30)
|
||||
assert w.width()==980 and w.height()==700
|
||||
lower,upper=w.detail_splitter.getRange(1)
|
||||
assert upper>lower
|
||||
assert w.plan_panel.table.viewport().height()>0
|
||||
assert w.run_panel.log_dialog is None
|
||||
w.run_panel.toggle_log_button.click();ui.settle()
|
||||
assert w.run_panel.log_dialog.isVisible()
|
||||
w.run_panel.toggle_log_button.click();ui.settle()
|
||||
assert w.run_panel.log_dialog is None
|
||||
|
||||
|
||||
def test_splitter_remains_draggable_while_background_work_is_running(qtbot, tmp_path):
|
||||
window, service, _, _ = make_window(qtbot, tmp_path)
|
||||
started = Event()
|
||||
release = Event()
|
||||
|
||||
def work():
|
||||
started.set()
|
||||
release.wait(3)
|
||||
return None
|
||||
|
||||
window._run_async(work, lambda _result: None, window.run_panel.quick_run_button)
|
||||
qtbot.waitUntil(started.is_set, timeout=1000)
|
||||
splitter = window.detail_splitter
|
||||
splitter.setSizes((230, 140, 190))
|
||||
before = splitter.sizes()[0]
|
||||
handle = splitter.handle(1)
|
||||
center = handle.rect().center()
|
||||
QTest.mousePress(handle, Qt.MouseButton.LeftButton, pos=center)
|
||||
QTest.mouseMove(handle, center + QPoint(0, 60), delay=20)
|
||||
QTest.mouseRelease(handle, Qt.MouseButton.LeftButton, pos=center + QPoint(0, 60))
|
||||
|
||||
assert splitter.sizes()[0] - before >= 40
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=3000)
|
||||
window.close()
|
||||
service._store.close()
|
||||
|
||||
|
||||
def test_layout_and_column_width_survive_window_recreation(qtbot, tmp_path):
|
||||
window, service, _, _ = make_window(qtbot, tmp_path)
|
||||
window.workspace_splitter.setSizes((320, 740))
|
||||
window.detail_splitter.setSizes((380, 190, 160))
|
||||
window.project_table.horizontalHeader().resizeSection(2, 240)
|
||||
qtbot.wait(20)
|
||||
expected = window.detail_splitter.sizes()
|
||||
window.close()
|
||||
recreated = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(recreated)
|
||||
recreated.show()
|
||||
qtbot.wait(20)
|
||||
assert abs(recreated.detail_splitter.sizes()[0] - expected[0]) <= 3
|
||||
assert recreated.project_table.columnWidth(2) == 240
|
||||
assert Path(service.layout_settings_path).is_relative_to(tmp_path)
|
||||
assert recreated.findChild(QToolButton, 'resetLayoutButton') is not None
|
||||
def test_rule_column_width_survives_window_recreation(ui,qtbot):
|
||||
w=ui.window;w.mapping_table.horizontalHeader().resizeSection(0,315)
|
||||
w.close();ui.settle()
|
||||
second=TrialTaskCenterWindow(ui.service);qtbot.addWidget(second)
|
||||
qtbot.waitUntil(lambda:not second._task_query.busy and not second._context_query.busy)
|
||||
assert second.mapping_table.horizontalHeader().sectionSize(0)==315
|
||||
second.close()
|
||||
@@ -174,7 +174,7 @@ End Sub
|
||||
('custom', '1M', 'True'), ('preserve', '1m', 'False'),
|
||||
])
|
||||
def test_recovery_requires_recorded_library_label_exactly(tmp_path, mode, label, expected):
|
||||
output = run_vbs(tmp_path, ATTRIBUTE_ROUTINES + ['QPRecoverSavedJob'], '''
|
||||
output = run_vbs(tmp_path, ATTRIBUTE_ROUTINES + ['QPRecoverSavedJob', 'QPTargetCell', 'QPDecode'], '''
|
||||
Set FakeComp = New FakeComponent
|
||||
FakeComp.PartLabel = "''' + label + '''"
|
||||
Set FakeRecords = CreateObject("Scripting.Dictionary")
|
||||
@@ -508,7 +508,7 @@ WScript.Echo CStr(InStr(Text, "G" & vbTab & "note" & vbTab) > 0)
|
||||
def test_capture_protects_unselected_and_does_not_hide_target_pn_error(tmp_path, read_failure, exact_scope):
|
||||
snapshot = str(tmp_path / 'captured.tsv')
|
||||
output = run_vbs(tmp_path, UNTOUCHED_ROUTINES + ['QPCaptureAndSelect', 'QPSnapshotComponent',
|
||||
'QPCommandTargets', 'QPBooleanText', 'QPLogField'], '''
|
||||
'QPCommandTargets', 'QPBooleanText', 'QPLogField', 'QPTargetCell'], '''
|
||||
Dim Comp, Other, Attr, Pin, Command, Records
|
||||
Set QP_App = New FakeApp
|
||||
Set Comp = New FullComponent: Comp.UID = "u1": Comp.Refdes = "R1"
|
||||
|
||||
Reference in new issue
Block a user