fix: preserve catalog state and verify PCB write access
This commit is contained in:
1 parent
3efeaed656
commit
86837155ea
11 files changed
+651
-92
No files matched your search
@@ -238,3 +238,43 @@ def test_catalog_native_wait_outlives_metadata_deadline(tmp_path, transport, mon
|
||||
(evidence/'finish').touch()
|
||||
finisher.join(6)
|
||||
context.close(timeout_seconds=6)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('switch', [False, True])
|
||||
def test_stop_reaches_active_catalog_adapter(qtbot, tmp_path, monkeypatch, transport, switch):
|
||||
from types import SimpleNamespace
|
||||
from cbb_refresh_verify.native_management import NativeManagementAdapter
|
||||
Transport, workers = transport
|
||||
original = Transport.__init__
|
||||
|
||||
def hold_until_signalled(self, command, *args, **kwargs):
|
||||
Path(command[-1]).with_name('hold-handler').touch()
|
||||
original(self, command, *args, **kwargs)
|
||||
|
||||
monkeypatch.setattr(Transport, '__init__', hold_until_signalled)
|
||||
library = tmp_path/'library.lmc'
|
||||
library.write_bytes(b'isolated')
|
||||
adapter = NativeManagementAdapter(worker_factory=Transport)
|
||||
window = window_for(qtbot, tmp_path/'ui', monkeypatch, catalog_reader=adapter.catalog)
|
||||
mapping_calls = []
|
||||
window.path_lease_factory = lambda path: SimpleNamespace(mentor_path=path, display_path=path,
|
||||
drive='', remote_root='', close=lambda: mapping_calls.append('close'),
|
||||
retain_for_recovery=lambda: mapping_calls.append('retain'))
|
||||
load(window, qtbot, str(library))
|
||||
qtbot.waitUntil(lambda: bool(workers) and workers[0].path.with_name('handler-entered').exists())
|
||||
worker = workers[0]
|
||||
try:
|
||||
if switch:
|
||||
window.lmc_edit.setText(str(tmp_path/'different.lmc'))
|
||||
else:
|
||||
window.stop_button.click()
|
||||
qtbot.waitUntil(lambda: worker.path.with_name('cancel-management.signal').exists(), timeout=3000)
|
||||
qtbot.waitUntil(lambda: bool(mapping_calls), timeout=3000)
|
||||
assert mapping_calls[0] == 'retain'
|
||||
if not switch:
|
||||
qtbot.waitUntil(lambda: '已取消读取中心库' in window.status_label.text(), timeout=3000)
|
||||
assert not window.native_queue.active
|
||||
assert worker.poll() is None
|
||||
finally:
|
||||
worker.path.with_name('finish').touch()
|
||||
qtbot.waitUntil(lambda: worker.poll() is not None, timeout=5000)
|
||||
Reference in new issue
Block a user