Core regression / Python core and release configuration (push) Successful in 17s
Core regression / JavaScript syntax (push) Successful in 2s
Core regression / Python core and release configuration (pull_request) Successful in 14s
Core regression / JavaScript syntax (pull_request) Successful in 3s
95 lines
4.3 KiB
Python
95 lines
4.3 KiB
Python
"""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 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_mapping_dialog_exposes_custom_value_nc_and_optional_cell(qtbot):
|
|
dialog=_MappingDialog(None,'OLD','NEW',True,True,'22uF',False)
|
|
qtbot.addWidget(dialog)
|
|
assert dialog.values()==('OLD','NEW',True,True,'22uF',False)
|
|
assert dialog.custom_value_edit.isEnabled()
|
|
assert dialog.target_cell=='' and '可选' in dialog.cell_combo.itemText(0)
|
|
|
|
|
|
def test_target_table_exposes_item_value_mode_selector(qtbot):
|
|
from pathlib import Path
|
|
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow
|
|
from dx_productivity.trial_task_center.ui.target_table import TargetTable
|
|
|
|
table = TargetTable()
|
|
qtbot.addWidget(table)
|
|
row = TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1', 'u1', 'R1', 'OLD', '10nF'),
|
|
True, 'NEW')
|
|
table.populate((row,))
|
|
assert table.model().index(0, 10).data() == 'inherit'
|
|
assert table.model().setData(table.model().index(0, 10), 'part_label')
|
|
assert table.rows()[0].value_mode == 'part_label'
|
|
assert not table.rows()[0].custom_value_enabled
|
|
assert table.model().setData(table.model().index(0, 10), 'custom')
|
|
assert table.rows()[0].value_mode == 'custom' and table.rows()[0].custom_value_enabled
|
|
|
|
from PySide6.QtCore import Qt
|
|
assert table.model().setData(table.model().index(0, 7), Qt.CheckState.Unchecked,
|
|
Qt.ItemDataRole.CheckStateRole)
|
|
assert table.rows()[0].value_mode == 'inherit' and not table.rows()[0].custom_value_enabled
|
|
assert table.plan_model.headerData(10, Qt.Orientation.Horizontal, Qt.ItemDataRole.ToolTipRole)
|
|
|
|
|
|
def test_target_value_editor_commits_selection_and_escape_cancels(qtbot):
|
|
from pathlib import Path
|
|
from PySide6.QtCore import Qt
|
|
from PySide6.QtWidgets import QComboBox
|
|
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow
|
|
from dx_productivity.trial_task_center.ui.target_table import TargetTable
|
|
|
|
table = TargetTable()
|
|
qtbot.addWidget(table)
|
|
table.resize(1400, 200)
|
|
table.populate((TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1', 'u1',
|
|
'R1', 'OLD', '10nF'), True, 'NEW'),))
|
|
table.show()
|
|
index = table.model().index(0, 10)
|
|
table.edit(index)
|
|
editor = table.findChild(QComboBox)
|
|
assert editor.currentText() == 'inherit'
|
|
editor.setCurrentText('part_number')
|
|
qtbot.keyClick(editor, Qt.Key.Key_Tab)
|
|
assert table.rows()[0].value_mode == 'part_number'
|
|
table.edit(index)
|
|
editor = next(e for e in table.findChildren(QComboBox) if e.isVisible())
|
|
editor.setCurrentText('custom')
|
|
qtbot.keyClick(editor, Qt.Key.Key_Escape)
|
|
assert table.rows()[0].value_mode == 'part_number'
|
|
|
|
|
|
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_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()
|