feat: scope CBB search selection and maintenance to visible non-READY rows
This commit is contained in:
1 parent
c823a4b92d
commit
747ce1add2
5 files changed
+572
-106
No files matched your search
+27
-17
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
os.environ.setdefault('QT_QPA_PLATFORM','offscreen')
|
||||
from cbb_refresh_verify.models import CbbRecord, LibraryReadResult
|
||||
@@ -21,7 +22,15 @@ def test_application_palette_keeps_table_text_readable(qtbot):
|
||||
|
||||
def fake_reader(_): return LibraryReadResult((CbbRecord('CBB1','Reusable Blocks'),))
|
||||
|
||||
def test_global_icdb_action_confirms_and_includes_ready_rows(qtbot, tmp_path, monkeypatch):
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def isolate_authoritative_native_refresh(monkeypatch):
|
||||
# Production refresh crosses the native Mentor boundary; these are UI tests.
|
||||
monkeypatch.setattr('cbb_refresh_verify.ui.main_window.authoritative_status_map',
|
||||
lambda names, *_: {name: 'READY' for name in names})
|
||||
|
||||
|
||||
def test_global_icdb_action_confirms_and_excludes_ready_rows(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
calls = []
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((
|
||||
@@ -37,7 +46,7 @@ def test_global_icdb_action_confirms_and_includes_ready_rows(qtbot, tmp_path, mo
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['READY', 'PENDING']
|
||||
assert calls == ['PENDING']
|
||||
|
||||
def test_global_icdb_action_disabled_without_library_or_while_busy(qtbot):
|
||||
window = MainWindow(reader=fake_reader)
|
||||
@@ -49,11 +58,11 @@ def test_global_icdb_action_disabled_without_library_or_while_busy(qtbot):
|
||||
window.busy = True; window._update()
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
|
||||
def test_global_icdb_failure_clears_ready_and_stops_queue(qtbot, tmp_path, monkeypatch):
|
||||
def test_global_icdb_failure_preserves_untargeted_ready_and_stops_queue(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
calls = []
|
||||
window = MainWindow(reader=lambda _: LibraryReadResult((
|
||||
CbbRecord('A', 'LP', status='READY'), CbbRecord('B', 'LP'))),
|
||||
CbbRecord('A', 'LP', status='READY'), CbbRecord('B', 'LP'), CbbRecord('C', 'LP'))),
|
||||
verifier=lambda req: (calls.append(req.block_name) or VerifyResult(
|
||||
'FAIL', stderr='unconfirmed', safe_to_continue=False)), data_root=tmp_path)
|
||||
qtbot.addWidget(window)
|
||||
@@ -62,10 +71,10 @@ def test_global_icdb_failure_clears_ready_and_stops_queue(qtbot, tmp_path, monke
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['A']
|
||||
assert 'A' not in window.ready_names
|
||||
assert window.cbb_table.item(0, 2).text() == '未知 / 需确认'
|
||||
assert window.cbb_table.item(1, 3).text().startswith('SKIPPED')
|
||||
assert calls == ['B']
|
||||
assert 'A' in window.ready_names
|
||||
assert window.cbb_table.item(1, 2).text() == '未知 / 需确认'
|
||||
assert window.cbb_table.item(2, 3).text().startswith('SKIPPED')
|
||||
|
||||
def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
@@ -83,11 +92,11 @@ def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
window.icdb_repair_button.click()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert 'lib.lmc' in confirmations[0]
|
||||
assert 'Ready' in confirmations[0]
|
||||
assert '非 READY' in confirmations[0]
|
||||
assert window.icdb_progress.value() == 1
|
||||
assert window.icdb_progress.maximum() == 1
|
||||
assert '恢复备份待复核 1' in window.status_label.text()
|
||||
assert window.summary.windowTitle() == '全库 ICDB 检查与修复结果'
|
||||
assert window.summary.windowTitle() == '非 READY ICDB 检查与修复结果'
|
||||
reports = list((tmp_path/'reports').glob('icdb-*.json'))
|
||||
assert len(reports) == 1
|
||||
|
||||
@@ -102,7 +111,7 @@ def test_ready_row_missing_project_is_skipped_by_global_maintenance(qtbot, tmp_p
|
||||
assert window.skipped_names == {'MISSING'}
|
||||
assert 'MISSING' not in window.ready_names
|
||||
assert not window.icdb_repair_button.isEnabled()
|
||||
assert window.cbb_table.item(0, 2).text().startswith('跳过')
|
||||
assert '缺少工程' in window.cbb_table.item(0, 2).text()
|
||||
|
||||
def test_verify_requires_loaded_library_and_invalidates_on_path_change(qtbot):
|
||||
window=MainWindow(reader=fake_reader, verifier=lambda _: VerifyResult('PASS')); qtbot.addWidget(window)
|
||||
@@ -156,8 +165,8 @@ def test_import_incomplete_rows_are_skipped_and_disabled(qtbot, tmp_path):
|
||||
window.lmc_edit.setText(str(lmc))
|
||||
window.load_library()
|
||||
qtbot.waitUntil(lambda: window.batch_button.isEnabled())
|
||||
assert window.cbb_table.item(0, 2).text().startswith('跳过:')
|
||||
assert not (window.cbb_table.item(0, 0).flags() & Qt.ItemIsUserCheckable)
|
||||
assert '缺少工程' in window.cbb_table.item(0, 2).text()
|
||||
assert window.cbb_table.item(0, 0).flags() & Qt.ItemIsUserCheckable
|
||||
window.verify_all()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['VALID_CBB']
|
||||
@@ -218,7 +227,7 @@ def test_large_library_load_does_not_update_controls_for_every_table_cell(qtbot,
|
||||
assert window._row_by_name['CBB_0299'] == 299
|
||||
assert len(calls) < 20
|
||||
|
||||
def test_ready_rows_show_status_and_cannot_be_selected_or_verified(qtbot, tmp_path):
|
||||
def test_ready_rows_allow_management_selection_but_cannot_be_verified(qtbot, tmp_path):
|
||||
def reader(_):
|
||||
return LibraryReadResult((CbbRecord('READY_CBB', 'LP', status='READY'), CbbRecord('PENDING_CBB', 'LP', status='PENDING')))
|
||||
calls = []
|
||||
@@ -229,15 +238,16 @@ def test_ready_rows_show_status_and_cannot_be_selected_or_verified(qtbot, tmp_pa
|
||||
qtbot.waitUntil(lambda: window.batch_button.isEnabled())
|
||||
assert window.cbb_table.columnCount() == 4
|
||||
assert window.cbb_table.item(0, 2).text() == '绿色 / Ready'
|
||||
assert not (window.cbb_table.item(0, 0).flags() & Qt.ItemIsUserCheckable)
|
||||
assert window.cbb_table.item(0, 0).flags() & Qt.ItemIsUserCheckable
|
||||
assert window.cbb_table.item(0, 0).background().color().name().lower() == '#e8f5e9'
|
||||
window.cbb_table.item(0, 0).setCheckState(Qt.Checked)
|
||||
assert 'READY_CBB' not in window._selected_names()
|
||||
assert 'READY_CBB' in window._selected_names()
|
||||
assert not window.selected_batch_button.isEnabled()
|
||||
window.verify_all()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['PENDING_CBB']
|
||||
assert window.cbb_table.item(1, 0).checkState() == Qt.Unchecked
|
||||
assert not (window.cbb_table.item(1, 0).flags() & Qt.ItemIsUserCheckable)
|
||||
assert window.cbb_table.item(1, 0).flags() & Qt.ItemIsUserCheckable
|
||||
assert window.cbb_table.item(1, 0).background().color().name().lower() == '#e8f5e9'
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user