fix: preserve mapped native paths and retain probe ownership guards
This commit is contained in:
1 parent
dd1fcea7e2
commit
46c3e72364
7 files changed
+365
-36
No files matched your search
@@ -78,25 +78,38 @@ def test_probe_cannot_use_existing_fixture_or_mutate_source(tmp_path):
|
||||
|
||||
|
||||
def test_probe_requires_owned_new_native_library_path(tmp_path):
|
||||
import os
|
||||
from cbb_refresh_verify.native_management import prepare_probe_library
|
||||
from cbb_refresh_verify.library_lock import LibraryLock
|
||||
outside = tmp_path/'production.lmc'; outside.write_bytes(b'unchanged')
|
||||
root = tmp_path/'worker'; root.mkdir()
|
||||
with pytest.raises(ValueError):
|
||||
prepare_probe_library({'library': str(outside)}, root)
|
||||
assert outside.read_bytes() == b'unchanged'
|
||||
owned = root/'fixture/mentor_lib.lmc'
|
||||
assert prepare_probe_library({'library': str(owned)}, root) == owned
|
||||
owned.write_bytes(b'first creation')
|
||||
with pytest.raises(ValueError):
|
||||
prepare_probe_library({'library': str(owned)}, root)
|
||||
owned.parent.mkdir()
|
||||
job = {'library': str(owned), 'probe_token': 'test-token', 'supervisor_pid': os.getpid()}
|
||||
(root/'probe-prepared.json').write_text(json.dumps({'library': str(owned), 'token': 'test-token',
|
||||
'supervisor_pid': os.getpid()}), encoding='utf-8')
|
||||
with LibraryLock(owned):
|
||||
assert prepare_probe_library(job, root) == owned
|
||||
owned.write_bytes(b'first creation')
|
||||
with pytest.raises(ValueError):
|
||||
prepare_probe_library(job, root)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('records', [[], [('Actual', 'Logical-Physical')]])
|
||||
def test_native_catalog_only_uses_com_records_and_checks_exact_process(tmp_path, monkeypatch, records):
|
||||
@pytest.mark.parametrize('mapped', [False, True])
|
||||
def test_native_catalog_only_uses_com_records_and_checks_exact_process(tmp_path, monkeypatch, records, mapped):
|
||||
import cbb_refresh_verify.native_management as native
|
||||
import cbb_refresh_verify.mentor_adapter as mentor
|
||||
import win32com.client
|
||||
library_path = tmp_path/'lib.lmc'; library_path.touch()
|
||||
if mapped:
|
||||
original_resolve = Path.resolve
|
||||
def resolve(path, *a, **k):
|
||||
return tmp_path/'canonical/lib.lmc' if path == library_path else original_resolve(path, *a, **k)
|
||||
monkeypatch.setattr(Path, 'resolve', resolve)
|
||||
(tmp_path/'ReusableBlocksLP/Ghost').mkdir(parents=True)
|
||||
class Collection:
|
||||
def __init__(self, items): self.items = items; self.Count = len(items)
|
||||
|
||||
Reference in new issue
Block a user