aboutsummaryrefslogtreecommitdiff
path: root/test/unit/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/utils.py')
-rw-r--r--test/unit/utils.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/unit/utils.py b/test/unit/utils.py
index 56880d5..85dee63 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -33,12 +33,9 @@ from ..script_loader import load_script
patterns_doc_url = \
'https://hydrillabugs.koszko.org/projects/haketilo/wiki/URL_patterns'
-def make_hash_key(file_contents):
- return f'sha256-{sha256(file_contents.encode()).digest().hex()}'
-
def sample_file(contents):
return {
- 'hash_key': make_hash_key(contents),
+ 'sha256': sha256(contents.encode()).digest().hex(),
'contents': contents
}
@@ -51,12 +48,12 @@ def make_sample_files(names_contents):
sample_files = dict([(name, sample_file(contents))
for name, contents in names_contents.items()])
- sample_files_by_hash = dict([[file['hash_key'], file['contents']]
- for file in sample_files.values()])
+ sample_files_by_sha256 = dict([[file['sha256'], file['contents']]
+ for file in sample_files.values()])
- return sample_files, sample_files_by_hash
+ return sample_files, sample_files_by_sha256
-sample_files, sample_files_by_hash = make_sample_files({
+sample_files, sample_files_by_sha256 = make_sample_files({
'report.spdx': '<!-- dummy report -->',
'LICENSES/somelicense.txt': 'Permission is granted...',
'LICENSES/CC0-1.0.txt': 'Dummy Commons...',
@@ -73,7 +70,7 @@ def sample_file_ref(file_name, sample_files_dict=sample_files):
"""
return {
'file': file_name,
- 'hash_key': sample_files_dict[file_name]['hash_key']
+ 'sha256': sample_files_dict[file_name]['sha256']
}
def make_sample_mapping(with_files=True):
@@ -154,7 +151,9 @@ def make_complete_sample_data():
return {
'resources': sample_data_dict([make_sample_resource()]),
'mappings': sample_data_dict([make_sample_mapping()]),
- 'files': sample_files_by_hash
+ 'file': {
+ 'sha256': sample_files_by_sha256
+ }
}
def clear_indexeddb(execute_in_page):