MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / test_file_matcher_closure

Function test_file_matcher_closure

tests/test_diff.py:387–420  ·  view source on GitHub ↗
(fixtures, tmp_path)

Source from the content-addressed store, hash-verified

385
386
387def test_file_matcher_closure(fixtures, tmp_path):
388 arch1 = fixtures.path("mirror/wheel-0.33.0-py2.py3-none-any.whl")
389 arch2 = fixtures.path("mirror/wheel-0.34.2-py2.py3-none-any.whl")
390 loc1 = ScanLocation(arch1, strip_path=os.fspath(fixtures.BASE_PATH))
391 loc2 = ScanLocation(arch2, strip_path=os.fspath(fixtures.BASE_PATH))
392
393 apath1 = tmp_path / "arch1"
394 apath2 = tmp_path / "arch2"
395
396 list(extract(loc1, destination=str(apath1)))
397 list(extract(loc2, destination=str(apath2)))
398
399 left_content = list(get_directory_content(apath1))
400 right_content = list(get_directory_content(apath2))
401
402 fm = diff.FileMatcher(left_content, right_content)
403 closure = fm.get_closure()
404 added = [str(x) for x in closure["added"]]
405 modified = {(str(x[0]), str(x[1])): x[2] for x in closure["modified"]}
406 removed = [str(x) for x in closure["removed"]]
407
408 for a in WHEEL_CLOSURE["added"]:
409 assert a in added
410
411 for r in WHEEL_CLOSURE["removed"]:
412 assert r in removed
413
414 for left_name, right_name, ratio in WHEEL_CLOSURE["modified"]:
415 assert (left_name, right_name) in modified
416 assert modified[(left_name, right_name)] == pytest.approx(ratio)
417
418 # Test that there are not duplicate elements on right or left side of modified files matches
419 assert len(set(x[0] for x in modified)) == len(modified)
420 assert len(set(x[1] for x in modified)) == len(modified)
421
422
423@mock.patch("aura.analyzers.archive.archive_analyzer")

Callers

nothing calls this directly

Calls 5

get_closureMethod · 0.95
ScanLocationClass · 0.90
extractFunction · 0.90
get_directory_contentFunction · 0.85
pathMethod · 0.80

Tested by

no test coverage detected