-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0515a73
commit 0b0387d
Showing
8 changed files
with
254 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from typeddfs.checksums import Checksums | ||
from typeddfs.checksums import ChecksumMappingOpt, Checksums | ||
from typeddfs.df_errors import ( | ||
HashContradictsExistingError, | ||
HashExistsError, | ||
HashFilenameMissingError, | ||
) | ||
|
||
|
||
class TestBuilders: | ||
def test(self): | ||
def test_get_algorithm(self): | ||
assert Checksums.get_algorithm("sha-256") == "sha256" | ||
|
||
def test_update(self): | ||
assert Checksums.get_updated_hashes({}, {}) == ChecksumMappingOpt({}) | ||
original = {Path("cat"): "0x5", "ok": "0x63"} | ||
update = {"cat": None, "other": "wads"} | ||
expected = { | ||
Path("cat").resolve(): None, | ||
Path("ok").resolve(): "0x63", | ||
Path("other").resolve(): "wads", | ||
} | ||
assert Checksums.get_updated_hashes(original, update) == ChecksumMappingOpt(expected) | ||
with pytest.raises(HashExistsError): | ||
Checksums.get_updated_hashes({"x": "5"}, {"x": "5"}, overwrite=False) | ||
assert Checksums.get_updated_hashes({"x": "5"}, {"x": "5"}, overwrite=None) == { | ||
Path("x").resolve(): "5" | ||
} | ||
with pytest.raises(HashContradictsExistingError): | ||
Checksums.get_updated_hashes({"x": "5"}, {"x": "4"}, overwrite=None) | ||
with pytest.raises(HashFilenameMissingError): | ||
Checksums.get_updated_hashes({}, {"x": "4"}, missing_ok=False) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.