aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCody Logan <clpo13@gmail.com>2019-08-05 23:48:24 -0700
committerCody Logan <clpo13@gmail.com>2019-08-05 23:48:24 -0700
commitdb3ccbdc25253ce24139ba506c71f582de911994 (patch)
tree2dc23e5fbe334fca40763ac35f41cec9d1493fb9 /test
parent0463a0bb2ecfbd18fcc89a7261cfa6d530035f67 (diff)
downloadwikiget-db3ccbdc25253ce24139ba506c71f582de911994.tar.gz
wikiget-db3ccbdc25253ce24139ba506c71f582de911994.zip
Add test for hash verification
Diffstat (limited to 'test')
-rw-r--r--test/test_wikiget.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test_wikiget.py b/test/test_wikiget.py
index 143bd71..1f0d3f0 100644
--- a/test/test_wikiget.py
+++ b/test/test_wikiget.py
@@ -5,6 +5,10 @@ Copyright (C) 2018-2019 Cody Logan; licensed GPLv3+
SPDX-License-Identifier: GPL-3.0-or-later
"""
+import os
+
+import pytest
+
from wikiget import wikiget
@@ -65,3 +69,23 @@ def test_valid_file_input():
for i in valid_input:
file_match = wikiget.valid_file(i)
assert file_match is not None
+
+
+def test_verify_hash():
+ """
+ Confirm that verify_hash returns the proper SHA1 hash.
+ """
+ # TODO: do we need to actually create a file?
+ file_name = "testfile"
+ file_contents = "foobar"
+ file_sha1 = "8843d7f92416211de9ebb963ff4ce28125932878"
+
+ try:
+ with open(file_name, "w") as dl:
+ dl.write(file_contents)
+ except PermissionError:
+ pytest.skip("need write access to create test file")
+
+ assert wikiget.verify_hash(file_name) == file_sha1
+
+ os.remove(file_name)