-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to output file with installer hashes (#816)
* Output hash for installer files * Add news file * Add missing _output_dir * Fix tests to check for two hashes * Remove line break from test files to achieve reproducibility between Unix and Windows * Update docs * Output one hash file per installers * Replace os.path with pathlib for all outputs * Remove EOL from JSON outputs * Revert "Remove EOL from JSON outputs" This reverts commit 5f65d34. * Revert "Replace os.path with pathlib for all outputs" This reverts commit b0f4f19. * Allow for algorithm list * Update constructor/build_outputs.py --------- Co-authored-by: jaimergp <[email protected]>
- Loading branch information
1 parent
9ff6bc7
commit 3bb0fd4
Showing
7 changed files
with
111 additions
and
4 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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Enhancements | ||
|
||
* Add option to output hashes of installer files. (#816) | ||
|
||
### Bug fixes | ||
|
||
* <news item> | ||
|
||
### Deprecations | ||
|
||
* <news item> | ||
|
||
### Docs | ||
|
||
* <news item> | ||
|
||
### Other | ||
|
||
* <news item> |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from constructor.build_outputs import dump_hash | ||
|
||
|
||
def test_hash_dump(tmp_path): | ||
testfile = tmp_path / "test.txt" | ||
testfile.write_text("test string") | ||
testfile = tmp_path / "test2.txt" | ||
testfile.write_text("another test") | ||
expected = { | ||
"sha256": ( | ||
"d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b", | ||
"64320dd12e5c2caeac673b91454dac750c08ba333639d129671c2f58cb5d0ad1", | ||
), | ||
"md5": ( | ||
"6f8db599de986fab7a21625b7916589c", | ||
"5e8862cd73694287ff341e75c95e3c6a", | ||
), | ||
} | ||
info = { | ||
"_outpath": [ | ||
str(tmp_path / "test.txt"), | ||
str(tmp_path / "test2.txt"), | ||
] | ||
} | ||
with pytest.raises(ValueError): | ||
dump_hash(info, algorithm="bad_algorithm") | ||
dump_hash(info, algorithm=["sha256", "md5"]) | ||
for f, file in enumerate(info["_outpath"]): | ||
for algorithm in expected: | ||
hashfile = Path(f"{file}.{algorithm}") | ||
assert hashfile.exists() | ||
filehash, filename = hashfile.read_text().strip().split() | ||
assert filehash == expected[algorithm][f] | ||
assert filename == Path(file).name |