mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-05 04:12:03 +00:00
test: verify verify_checksum behavior when file is missing
Added a new test case `test_verify_checksum_missing` to `src/tests/test_checksum_utils.py` to ensure that `verify_checksum` correctly raises `FileNotFoundError` and logs an appropriate error message when the checksum file does not exist. This improves diagnostic reliability for checksum verification failures. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
88781479aa
commit
00d19d90f7
1 file changed
+9
@@ -2,6 +2,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
from utils import checksum
|
from utils import checksum
|
||||||
|
|
||||||
|
|
||||||
@@ -45,3 +46,11 @@ def test_initialize_checksum(tmp_path):
|
|||||||
assert checksum.initialize_checksum(str(data), str(chk_file))
|
assert checksum.initialize_checksum(str(data), str(chk_file))
|
||||||
expected = hashlib.sha256("payload".encode()).hexdigest()
|
expected = hashlib.sha256("payload".encode()).hexdigest()
|
||||||
assert chk_file.read_text() == expected
|
assert chk_file.read_text() == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_verify_checksum_missing(tmp_path, caplog):
|
||||||
|
missing_file = tmp_path / "missing_chk.txt"
|
||||||
|
with pytest.raises(FileNotFoundError):
|
||||||
|
checksum.verify_checksum("abc", str(missing_file))
|
||||||
|
|
||||||
|
assert f"Checksum file '{missing_file}' not found." in caplog.text
|
||||||
Reference in new issue
Block a user