summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-11-07 18:32:02 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-11-07 18:32:04 -0800
commitd994d11d90a6e7af7f9df39e90515c0fa633cfc5 (patch)
tree8f8e96e538e581251e40ef68e628b42d1fb56c97 /python/tests
parent87a009f758e7eea4f2fe4395d6f52364fe836212 (diff)
downloadfatcat-d994d11d90a6e7af7f9df39e90515c0fa633cfc5.tar.gz
fatcat-d994d11d90a6e7af7f9df39e90515c0fa633cfc5.zip
fix test_file_metadata_parse
This test was failing after the first run because the database was getting updated. Randomizing the SHA1 means this should run repeatably.
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/grobid_metadata_importer.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/tests/grobid_metadata_importer.py b/python/tests/grobid_metadata_importer.py
index 7bbabb39..2c8565aa 100644
--- a/python/tests/grobid_metadata_importer.py
+++ b/python/tests/grobid_metadata_importer.py
@@ -1,5 +1,7 @@
+import os
import json
+import base64
import pytest
from fatcat.grobid_metadata_importer import FatcatGrobidMetadataImporter
@@ -34,10 +36,12 @@ def test_file_metadata_parse(grobid_metadata_importer):
with open('tests/files/example_grobid_metadata_lines.tsv', 'r') as f:
f.readline()
raw = f.readline().split('\t')
+ # randomize sha1 so tests are repeatable
+ random_sha1 = "sha1:{}".format(base64.b32encode(os.urandom(20)).decode('utf-8').upper())
fe = grobid_metadata_importer.parse_file_metadata(
- raw[0], json.loads(raw[1]), raw[2], int(raw[3]))
+ random_sha1, json.loads(raw[1]), raw[2], int(raw[3]))
assert fe
- assert fe.sha1 == "d4a841744719518bf8bdd5d91576ccedc55efbb5" # "sha1:2SUEC5CHDFIYX6F52XMRK5WM5XCV565V"
+ #assert fe.sha1 == "d4a841744719518bf8bdd5d91576ccedc55efbb5" # "sha1:2SUEC5CHDFIYX6F52XMRK5WM5XCV565V"
assert fe.md5 == None
assert fe.mimetype == "application/pdf"
assert fe.size == 142710