Files
dxdesigner-part-replacement/tests/v1_1/test_target_table.py
T

44 lines
1.9 KiB
Python

import os
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
from pathlib import Path
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow
from dx_productivity.trial_task_center.ui.target_table import TargetTable
def test_edit_targets_and_nc_in_original_view_without_excel():
app = QApplication.instance() or QApplication([])
table = TargetTable()
rows = tuple(TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1', uid,
refdes, 'OLD', value), False, 'NEW')
for uid, refdes, value in [('u1', 'R1', 'A/NC'), ('u2', 'R2', 'B')])
table.populate(rows)
table.item(0, 0).setCheckState(Qt.CheckState.Checked)
table.item(0, 6).setText('NEW-2')
table.item(0, 7).setCheckState(Qt.CheckState.Checked)
table.item(0, 8).setText('100nF/10V')
table.item(0, 9).setCheckState(Qt.CheckState.Unchecked)
edited = table.rows()
assert edited[0].target == rows[0].target
assert edited[0].enabled and edited[0].new_part_number == 'NEW-2'
assert edited[0].custom_value == '100nF/10V' and not edited[0].sync_nc
assert not edited[1].enabled and edited[1].target.uid == 'u2'
assert table.dirty
assert not table.item(0, 3).flags() & Qt.ItemFlag.ItemIsEditable
table.close()
def test_table_lock_blocks_editing_and_selection():
app = QApplication.instance() or QApplication([])
table = TargetTable()
table.populate((TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1',
'u1', 'R1', 'OLD', 'A')),))
table.set_plan_editable(False)
assert not table.item(0, 0).flags() & Qt.ItemFlag.ItemIsUserCheckable
assert not table.item(0, 6).flags() & Qt.ItemFlag.ItemIsEditable
table.close()