-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
1 changed file
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import time | ||
|
||
from mock import mock_open, patch | ||
|
||
from publish2cloud import chunk_metadata | ||
|
||
|
||
def test_chunk_metadata(): | ||
"""Test getting metadata from the chunk header of a list file.""" | ||
chunknum = int(time.time()) | ||
# Hash of test-track-digest256.dummytracker.org/ | ||
domain_hash = (b"q\xd8Q\xbe\x8b#\xad\xd9\xde\xdf\xa7B\x12\xf0D\xa2" | ||
"\xf2\x1d\xcfx\xeaHi\x7f8%\xb5\x99\x83\xc1\x111") | ||
data = b"a:%d:32:32\n" % chunknum + domain_hash | ||
|
||
with patch("test_publish2cloud.open", mock_open(read_data=data)): | ||
with open("base-fingerprinting-track-digest256", "rb") as fp: | ||
metadata = chunk_metadata(fp) | ||
|
||
assert metadata["type"] == "a" | ||
assert metadata["num"] == str(chunknum) | ||
assert metadata["hash_size"] == "32" | ||
assert metadata["len"] == "32" | ||
assert metadata["checksum"] == ("043493ecb63c5f143a372a5118d04a44df" | ||
"188f238d2b18e6cd848ae413a01090") |