Skip to content

Commit 6f50998

Browse files
author
Lukas Puehringer
committed
Add tests for custom blake hash
Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
1 parent 535a189 commit 6f50998

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,12 @@ def test_length_and_hash_validation(self) -> None:
895895
# test with data as bytes
896896
snapshot_metafile.verify_length_and_hashes(data)
897897

898+
# test with custom blake algorithm
899+
snapshot_metafile.hashes = {
900+
"blake2b-256": "963a3c31aad8e2a91cfc603fdba12555e48dd0312674ac48cce2c19c243236a1"
901+
}
902+
snapshot_metafile.verify_length_and_hashes(data)
903+
898904
# test exceptions
899905
expected_length = snapshot_metafile.length
900906
snapshot_metafile.length = 2345
@@ -987,6 +993,12 @@ def test_targetfile_from_data(self) -> None:
987993
targetfile_from_data = TargetFile.from_data(target_file_path, data)
988994
targetfile_from_data.verify_length_and_hashes(data)
989995

996+
# Test with custom blake hash algorithm
997+
targetfile_from_data = TargetFile.from_data(
998+
target_file_path, data, ["blake2b-256"]
999+
)
1000+
targetfile_from_data.verify_length_and_hashes(data)
1001+
9901002
def test_metafile_from_data(self) -> None:
9911003
data = b"Inline test content"
9921004

@@ -1010,6 +1022,10 @@ def test_metafile_from_data(self) -> None:
10101022
),
10111023
)
10121024

1025+
# Test with custom blake hash algorithm
1026+
metafile = MetaFile.from_data(1, data, ["blake2b-256"])
1027+
metafile.verify_length_and_hashes(data)
1028+
10131029
def test_targetfile_get_prefixed_paths(self) -> None:
10141030
target = TargetFile(100, {"sha256": "abc", "md5": "def"}, "a/b/f.ext")
10151031
self.assertEqual(

0 commit comments

Comments
 (0)