fix: report known catalog conflicts before WMI startup
This commit is contained in:
1 parent
0ee24d7beb
commit
75612cd4da
4 files changed
+88
-17
No files matched your search
@@ -27,7 +27,7 @@ def test_status_scan_delivers_progress_after_each_record(tmp_path):
|
||||
def test_catalog_registration_only_skips_project_identities(tmp_path, monkeypatch, include_identity, unknown_foreign):
|
||||
import win32com.client
|
||||
import win32process
|
||||
from cbb_refresh_verify import mentor_adapter
|
||||
from cbb_refresh_verify import mentor_adapter, owner_probe
|
||||
|
||||
lmc = tmp_path / 'lib.lmc'
|
||||
lmc.touch()
|
||||
@@ -46,6 +46,7 @@ def test_catalog_registration_only_skips_project_identities(tmp_path, monkeypatc
|
||||
previous = [(321, str(exe), '', 0)] if unknown_foreign else []
|
||||
snapshots = iter([previous, [*previous, (123, str(exe), '', 0)]])
|
||||
monkeypatch.setattr(mentor_adapter, '_process_details', lambda _: next(snapshots))
|
||||
monkeypatch.setattr(owner_probe, 'snapshot_process_ids', lambda _: [])
|
||||
if unknown_foreign:
|
||||
exe.parent.mkdir(parents=True)
|
||||
exe.write_bytes(b'library manager')
|
||||
@@ -66,6 +67,26 @@ def test_catalog_registration_only_skips_project_identities(tmp_path, monkeypatc
|
||||
assert hashed == ([project] if include_identity else [])
|
||||
|
||||
|
||||
def test_catalog_reports_exact_same_library_before_slow_owner_lookup(tmp_path, monkeypatch):
|
||||
import win32com.client
|
||||
from cbb_refresh_verify import mentor_adapter, owner_probe
|
||||
|
||||
library = tmp_path / 'lib.lmc'
|
||||
library.touch()
|
||||
monkeypatch.setattr(native, '_current_desktop', lambda: (None, 'CbbManagement_test'))
|
||||
monkeypatch.setattr(owner_probe, 'snapshot_process_ids', lambda name: [123], raising=False)
|
||||
monkeypatch.setattr(native, '_open_catalog_manager_library', lambda pid: library)
|
||||
monkeypatch.setattr(mentor_adapter, '_process_details', lambda name: pytest.fail('slow owner lookup'))
|
||||
monkeypatch.setattr(win32com.client, 'DispatchEx', lambda name: pytest.fail('busy library was opened'))
|
||||
|
||||
with pytest.raises(native.NativeOperationError, match='LIBRARY_MANAGER_BUSY.*123') as caught:
|
||||
native._catalog_com({'operation': 'catalog', 'worker_role': 'catalog_readonly',
|
||||
'include_engineering_identity': False, 'library': str(library),
|
||||
'desktop': 'CbbManagement_test', 'mentor_home': str(tmp_path)}, tmp_path)
|
||||
assert caught.value.safe_to_continue is True
|
||||
assert caught.value.blocking_manager_pids == (123,)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('scope', ['foreign', 'same', 'shared', 'unknown', 'switched', 'occupied'])
|
||||
def test_catalog_distinguishes_foreign_and_conflicting_manager(tmp_path, monkeypatch, scope):
|
||||
target = tmp_path/'target'/'lib.lmc'
|
||||
@@ -99,7 +120,7 @@ def test_catalog_distinguishes_foreign_and_conflicting_manager(tmp_path, monkeyp
|
||||
@pytest.mark.parametrize('title_resolved', [True, False])
|
||||
def test_catalog_rejects_reused_foreign_com_proxy_without_mutating_it(tmp_path, monkeypatch, title_resolved):
|
||||
import win32com.client
|
||||
from cbb_refresh_verify import mentor_adapter
|
||||
from cbb_refresh_verify import mentor_adapter, owner_probe
|
||||
|
||||
target = tmp_path/'target'/'lib.lmc'
|
||||
other = tmp_path/'other'/'lib.lmc'
|
||||
@@ -112,6 +133,7 @@ def test_catalog_rejects_reused_foreign_com_proxy_without_mutating_it(tmp_path,
|
||||
monkeypatch.setitem(native._BINARY_PROOF, 'lm/win32/bin/LibraryManager.exe', native.hash_file(exe))
|
||||
before = [(123, 'LibraryManager.exe', f'LibraryManager.exe "{other}"', 0)]
|
||||
monkeypatch.setattr(mentor_adapter, '_process_details', lambda _: before)
|
||||
monkeypatch.setattr(owner_probe, 'snapshot_process_ids', lambda _: [])
|
||||
monkeypatch.setattr(native, '_open_catalog_manager_library', lambda _: other if title_resolved else None)
|
||||
monkeypatch.setattr(native, '_current_desktop',
|
||||
lambda: (SimpleNamespace(EnumDesktopWindows=lambda: []), 'CbbManagement_test'))
|
||||
|
||||
Reference in new issue
Block a user