|
2 | 2 | from unittest import TestCase
|
3 | 3 |
|
4 | 4 | from pyntegrity.core import detect_hash_algo
|
5 |
| -from pyntegrity.core import get_file_path_from_str |
| 5 | +from pyntegrity.core import IntegrityValidator |
6 | 6 | from pyntegrity.core import validate_checksum_str
|
| 7 | +from pyntegrity.core import get_file_path_from_str |
7 | 8 |
|
8 | 9 | from pyntegrity.exceptions import FileNotFoundException
|
9 | 10 | from pyntegrity.exceptions import ObjectNotAFileException
|
@@ -62,3 +63,19 @@ def test_get_file_path_from_str_nok_is_not_file(self):
|
62 | 63 | def test_get_file_path_from_str_nok_not_found(self):
|
63 | 64 | with self.assertRaises(FileNotFoundException):
|
64 | 65 | get_file_path_from_str("tests/data/doesnt_exists.csv")
|
| 66 | + |
| 67 | + |
| 68 | +class TestGetFileChecksum(TestCase): |
| 69 | + def test_get_file_checksum_text(self): |
| 70 | + obj = IntegrityValidator( |
| 71 | + str_path="tests/data/test_file.txt", |
| 72 | + checksum_str="bbe4f28b27120e0a9611d90d242bc656", |
| 73 | + ) |
| 74 | + self.assertEqual(obj.get_file_checksum(), "bbe4f28b27120e0a9611d90d242bc656") |
| 75 | + |
| 76 | + def test_get_file_checksum_bin(self): |
| 77 | + obj = IntegrityValidator( |
| 78 | + str_path="tests/data/test_file.dat", |
| 79 | + checksum_str="0cb988d042a7f28dd5fe2b55b3f5ac7a", |
| 80 | + ) |
| 81 | + self.assertEqual(obj.get_file_checksum(), "0cb988d042a7f28dd5fe2b55b3f5ac7a") |
0 commit comments