From e41e8ab92d038a99c97439e489071211da3329cb Mon Sep 17 00:00:00 2001 From: bnewbold Date: Fri, 26 May 2017 00:13:59 -0700 Subject: add some very basic test files --- tests/correct.sha1 | 3 +++ tests/tarsum.py | 25 +++++++++++++++++++++++++ tests/test.tar.gz | Bin 0 -> 1485 bytes tests/test.zip | Bin 0 -> 1900 bytes 4 files changed, 28 insertions(+) create mode 100644 tests/correct.sha1 create mode 100755 tests/tarsum.py create mode 100644 tests/test.tar.gz create mode 100644 tests/test.zip diff --git a/tests/correct.sha1 b/tests/correct.sha1 new file mode 100644 index 0000000..f272748 --- /dev/null +++ b/tests/correct.sha1 @@ -0,0 +1,3 @@ +36e01a203d190da18a25071b8d9f6e1312df8a78 junk_files/blank.jpg +aac0af8f10f31fa4d863eb984fbb1f50a21ac753 junk_files/lorem.txt +bc9d478235544fe6436d461461118eb47d9ae098 junk_files/small.txt diff --git a/tests/tarsum.py b/tests/tarsum.py new file mode 100755 index 0000000..23d397d --- /dev/null +++ b/tests/tarsum.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +""" +From: https://gist.github.com/DaveCTurner/8765561 + +Modified to print with an extra space between fields +""" + +import sys +import tarfile +import hashlib + +for filename in sys.argv[1:]: + print filename + with tarfile.open(filename, 'r') as tar: + for tarinfo in tar: + if tarinfo.isreg(): + flo = tar.extractfile(tarinfo) # NB doesn't really extract the file, just gives you a stream (file-like-object) for reading it + hash = hashlib.sha1() + while True: + data = flo.read(2**20) + if not data: + break + hash.update(data) + flo.close() + print hash.hexdigest(), '', tarinfo.name diff --git a/tests/test.tar.gz b/tests/test.tar.gz new file mode 100644 index 0000000..6b547f4 Binary files /dev/null and b/tests/test.tar.gz differ diff --git a/tests/test.zip b/tests/test.zip new file mode 100644 index 0000000..d7e828d Binary files /dev/null and b/tests/test.zip differ -- cgit v1.2.3