18 lines
518 B
Python
18 lines
518 B
Python
|
|
from pathlib import Path
|
||
|
|
from core.integrity_checker import IntegrityChecker
|
||
|
|
|
||
|
|
|
||
|
|
def test_calculate_and_verify_hash(tmp_path: Path):
|
||
|
|
file = tmp_path / "data.txt"
|
||
|
|
file.write_text("hello", encoding="utf-8")
|
||
|
|
|
||
|
|
hash_file = tmp_path / "data.hash"
|
||
|
|
checker = IntegrityChecker()
|
||
|
|
|
||
|
|
checker.save_hash(file, hash_file)
|
||
|
|
assert checker.verify_hash(file, hash_file)
|
||
|
|
|
||
|
|
# Нарушим целостность
|
||
|
|
file.write_text("changed", encoding="utf-8")
|
||
|
|
assert not checker.verify_hash(file, hash_file)
|