-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add checksum timestamp changes (#371)
* add checksum timestamp changes * style: black reformat * style: DRY * add unit test --------- Co-authored-by: Donny Winston <[email protected]>
- Loading branch information
Showing
4 changed files
with
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import datetime, timedelta | ||
from pathlib import Path | ||
from zoneinfo import ZoneInfo | ||
|
||
from nmdc_runtime.api.core.util import sha256hash_from_file | ||
|
||
TEST_FILES_DIR = Path(__file__).parent.parent.joinpath("files") | ||
|
||
|
||
def test_sha256hash_from_file_is_timestamp_dependent(): | ||
file_path = str(TEST_FILES_DIR.joinpath("test_changesheet_update_one_ph.tsv")) | ||
ts_1 = datetime.now(tz=ZoneInfo("America/Los_Angeles")) | ||
ts_2 = ts_1 + timedelta(minutes=1) | ||
hashes = [] | ||
for ts in (ts_1, ts_2): | ||
hashes.append( | ||
sha256hash_from_file( | ||
file_path=file_path, timestamp=ts.isoformat(timespec="minutes") | ||
) | ||
) | ||
assert hashes[0] != hashes[1] |