fix: keep resource checks responsive and retain import diagnostics
This commit is contained in:
1 parent
7bdaaeb2ec
commit
656f43e2ff
20 files changed
+455
-48
No files matched your search
@@ -0,0 +1,90 @@
|
||||
"""UI log and feedback coverage, collectable alongside the service feedback tests."""
|
||||
import json
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from dx_productivity.trial_task_center.ui.messages import (
|
||||
_aligned_log_line, _format_task_log_lines, _nc_sync_log_lines,
|
||||
)
|
||||
|
||||
|
||||
def test_nc_sync_evidence_is_formatted_for_operator_log():
|
||||
message = (
|
||||
'Native replacement passed. NC synced: '
|
||||
'R1 R0603/NC -> R0805/NC (detected /NC and synchronized); '
|
||||
'C2 C0603/NC -> C0805/NC (detected /NC and synchronized)'
|
||||
)
|
||||
assert _nc_sync_log_lines(message) == (
|
||||
'位号 R1 R0603/NC -> R0805/NC,识别到 NC,已同步',
|
||||
'位号 C2 C0603/NC -> C0805/NC,识别到 NC,已同步',
|
||||
)
|
||||
|
||||
|
||||
def test_task_event_json_is_rendered_as_readable_operator_text():
|
||||
line = json.dumps({
|
||||
'timestamp_utc': '2026-09-06T10:55:34.796685Z',
|
||||
'level': 'INFO',
|
||||
'operation': 'value_policy_changed',
|
||||
'message': '',
|
||||
'details': {'copy_part_number_to_value': True},
|
||||
})
|
||||
|
||||
assert _format_task_log_lines((line, 'legacy line')) == (
|
||||
'2026-09-06 10:55:34 | INFO | value_policy_changed | Value 选项已更新:替换后写入目标 Part Label。',
|
||||
' | INFO | legacy | legacy line',
|
||||
)
|
||||
|
||||
|
||||
def test_log_operation_column_stays_aligned_for_long_names():
|
||||
line = _aligned_log_line(
|
||||
'2026-09-10 12:34:56',
|
||||
'WARNING',
|
||||
'operation_name_that_is_longer_than_the_column',
|
||||
'内容',
|
||||
)
|
||||
|
||||
assert line.index(' | 内容') == 19 + 3 + 7 + 3 + 28
|
||||
assert 'operation_name_that_is_lo...' in line
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def test_running_feedback_names_owner_and_keeps_navigation_available(ui,qtbot):
|
||||
from threading import Event
|
||||
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._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:
|
||||
release.set()
|
||||
ui.settle()
|
||||
assert window._batch_stop is None and window._task_id==ui.tasks[1].task_id
|
||||
|
||||
|
||||
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
|
||||
Reference in new issue
Block a user