diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 17:09:13 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 18:00:16 +0100 |
commit | 1c65dd5ca24052ccf9a92939eecd0966c9635c50 (patch) | |
tree | 7575157ccd729b4ad79f6c04501023ccb0532a63 /test/unit/utils.py | |
parent | 830d22d8931a4e5f0606d401f24d7cd937f8697e (diff) | |
download | browser-extension-1c65dd5ca24052ccf9a92939eecd0966c9635c50.tar.gz browser-extension-1c65dd5ca24052ccf9a92939eecd0966c9635c50.zip |
adapt to changes in file path format
From now on we assume Hydrilla serves file contents at 'file/sha256/<hash>' instead of 'file/sha256-<hash>'.
With this commit we also stop using the "hash_key" property internally.
Diffstat (limited to 'test/unit/utils.py')
-rw-r--r-- | test/unit/utils.py | 19 |
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): |