feat: preview and batch import independent verification pairs
This commit is contained in:
1 parent
9ccf99bd8f
commit
eda9403d94
8 files changed
+508
-6
No files matched your search
@@ -0,0 +1,100 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from threading import Event
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parents[1]/'v1_1'))
|
||||
from test_native_cli_netlist import project_fixture
|
||||
|
||||
|
||||
def projects(tmp_path):
|
||||
roots = tmp_path/'before', tmp_path/'after'
|
||||
for root in roots:
|
||||
for name in ('A', 'B'):
|
||||
directory = root/name
|
||||
directory.mkdir(parents=True)
|
||||
project_fixture(directory)
|
||||
directory = roots[0]/'only-before'
|
||||
directory.mkdir()
|
||||
project_fixture(directory)
|
||||
return roots
|
||||
|
||||
|
||||
def test_batch_preview_imports_only_checked_pairs_without_running_verification(ui, qtbot, tmp_path):
|
||||
from dx_productivity.trial_task_center.ui.verification_batch_import import VerificationBatchDialog
|
||||
page = ui.window.verification_panel
|
||||
task = page.service.create_task('批量', request_id='batch')['task_id']
|
||||
page.open_task(task)
|
||||
page.batch_button.click()
|
||||
dialog = page._batch_dialog
|
||||
assert isinstance(dialog, VerificationBatchDialog) and dialog.isVisible() and not dialog.isModal()
|
||||
before, after = projects(tmp_path)
|
||||
dialog.before.setText(str(before)); dialog.after.setText(str(after))
|
||||
dialog.scan.click()
|
||||
qtbot.waitUntil(lambda: not dialog.busy)
|
||||
assert dialog.table.rowCount() == 3
|
||||
assert dialog.table.item(2, 0).checkState() == Qt.CheckState.Unchecked
|
||||
assert not dialog.table.item(2, 0).flags() & Qt.ItemFlag.ItemIsUserCheckable
|
||||
dialog.table.item(1, 0).setCheckState(Qt.CheckState.Unchecked)
|
||||
dialog.import_button.click()
|
||||
qtbot.waitUntil(lambda: not dialog.busy)
|
||||
data = page.service.read_task(task)
|
||||
assert data['summary']['total'] == 1
|
||||
assert data['items'][0]['display_name'] == 'A/source/board.prj'
|
||||
assert data['summary']['waiting'] == 1
|
||||
assert page.new_button.isEnabled() and dialog.import_button.isEnabled() is False
|
||||
assert page.service.repo.connection.execute('SELECT COUNT(*) FROM verification_attempts').fetchone()[0] == 0
|
||||
dialog.reject()
|
||||
|
||||
|
||||
def test_batch_cancel_keeps_first_pair_and_main_page_can_create_another_task(ui, qtbot, tmp_path, monkeypatch):
|
||||
from dx_productivity.trial_task_center.ui.verification_batch_import import VerificationBatchDialog
|
||||
page = ui.window.verification_panel
|
||||
task = page.service.create_task('批量', request_id='batch')['task_id']
|
||||
page.open_task(task)
|
||||
dialog = VerificationBatchDialog(page.service, page.controller, task, '批量', page)
|
||||
qtbot.addWidget(dialog)
|
||||
before, after = projects(tmp_path)
|
||||
dialog.before.setText(str(before)); dialog.after.setText(str(after)); dialog.scan.click()
|
||||
qtbot.waitUntil(lambda: not dialog.busy)
|
||||
entered, release = Event(), Event()
|
||||
original = page.service.import_pair
|
||||
def slow(*args, **kwargs):
|
||||
result = original(*args, **kwargs)
|
||||
entered.set(); release.wait(5)
|
||||
return result
|
||||
monkeypatch.setattr(page.service, 'import_pair', slow)
|
||||
dialog.import_button.click()
|
||||
qtbot.waitUntil(entered.is_set)
|
||||
try:
|
||||
assert page.new_button.isEnabled()
|
||||
other = page.service.create_task('另一个任务', request_id='other')['task_id']
|
||||
assert other != task
|
||||
dialog.cancel_button.click()
|
||||
finally:
|
||||
release.set()
|
||||
qtbot.waitUntil(lambda: not dialog.busy)
|
||||
assert page.service.read_task(task)['summary']['total'] == 1
|
||||
dialog.reject()
|
||||
|
||||
|
||||
def test_closing_preview_cancels_scan_without_late_table_changes(ui, qtbot, tmp_path, monkeypatch):
|
||||
from dx_productivity.trial_task_center.ui.verification_batch_import import VerificationBatchDialog
|
||||
page = ui.window.verification_panel
|
||||
task = page.service.create_task('关闭读取', request_id='batch')['task_id']
|
||||
dialog = VerificationBatchDialog(page.service, page.controller, task, '关闭读取', page)
|
||||
qtbot.addWidget(dialog)
|
||||
before, after = projects(tmp_path)
|
||||
entered, release = Event(), Event()
|
||||
scan = page.service.preview_pairs
|
||||
def slow(*args, **kwargs):
|
||||
entered.set(); release.wait(5)
|
||||
return scan(*args, **kwargs)
|
||||
monkeypatch.setattr(page.service, 'preview_pairs', slow)
|
||||
dialog.before.setText(str(before)); dialog.after.setText(str(after)); dialog.scan.click()
|
||||
qtbot.waitUntil(entered.is_set)
|
||||
dialog.reject(); release.set()
|
||||
qtbot.waitUntil(lambda: not page.controller.workers)
|
||||
assert not dialog.busy and dialog.table.rowCount() == 0
|
||||
assert page.service.read_task(task)['summary']['total'] == 0
|
||||
Reference in new issue
Block a user