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
@@ -252,3 +252,52 @@ def test_verify_exception_after_upload_retains_coordination_lock(setup):
|
||||
with pytest.raises(LibraryBusy):
|
||||
with LibraryLock(request.library):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.parametrize('nested', [True, False])
|
||||
def test_library_inside_source_tree_rejected_before_catalog_or_guard(setup, nested):
|
||||
request, adapter, source = setup
|
||||
library = source.parent/('nested/lib.lmc' if nested else 'lib.lmc')
|
||||
library.parent.mkdir(exist_ok=True)
|
||||
library.write_bytes(b'library')
|
||||
adapter.catalog = lambda *a: pytest.fail('overlapping library reached native catalog')
|
||||
result = execute(replace(request, operation='add', name='New', source=source, library=library), adapter)
|
||||
assert result.status == 'BLOCKED' and not adapter.calls
|
||||
assert not library.with_name('.lib.cbb-upload.lock').exists()
|
||||
assert not request.evidence_dir.exists()
|
||||
|
||||
|
||||
def test_mapped_library_spelling_and_context_survive_engine_verify_boundary(setup, monkeypatch):
|
||||
import shutil
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
request, adapter, source = setup
|
||||
alias_root = request.library.parent
|
||||
canonical_root = alias_root.with_name('canonical-library')
|
||||
shutil.copytree(alias_root, canonical_root)
|
||||
original_resolve = Path.resolve
|
||||
def resolve(path, *a, **k):
|
||||
if path.is_relative_to(alias_root):
|
||||
return original_resolve(canonical_root/path.relative_to(alias_root), *a, **k)
|
||||
return original_resolve(path, *a, **k)
|
||||
monkeypatch.setattr(Path, 'resolve', resolve)
|
||||
catalogs, verified = [], []
|
||||
catalog = adapter.catalog
|
||||
adapter.catalog = lambda library, evidence: (catalogs.append(library) or catalog(library, evidence))
|
||||
def verifier(req, **k):
|
||||
verified.append(req)
|
||||
return VerifyResult('PASS', library_flag='GREEN')
|
||||
request = replace(request, operation='add', name='New', source=source,
|
||||
mapped_drive='S:', mapped_remote_root=r'\\server\share')
|
||||
result = execute(request, adapter, verifier=verifier)
|
||||
assert result.status == 'UPLOADED_VERIFIED'
|
||||
assert catalogs == [request.library, request.library]
|
||||
assert verified[0].lmc_file == request.library
|
||||
assert verified[0].mapped_drive == 'S:' and verified[0].mapped_remote_root == r'\\server\share'
|
||||
|
||||
|
||||
def test_source_inside_target_library_rejected_before_catalog(setup):
|
||||
request, adapter, _ = setup
|
||||
source = request.library.parent/'ReusableBlocksLP/Block/Work/Block.prj'
|
||||
adapter.catalog = lambda *a: pytest.fail('overlapping source reached native catalog')
|
||||
result = execute(replace(request, operation='add', name='New', source=source), adapter)
|
||||
assert result.status == 'BLOCKED' and not request.evidence_dir.exists()
|
||||
Reference in new issue
Block a user