Project

General

Profile

« Previous | Next » 

Revision 1c65dd5c

Added by koszko over 1 year ago

adapt to changes in file path format

From now on we assume Hydrilla serves file contents at 'file/sha256/' instead of 'file/sha256-'.
With this commit we also stop using the "hash_key" property internally.

View differences:

test/unit/utils.py
33 33
patterns_doc_url = \
34 34
    'https://hydrillabugs.koszko.org/projects/haketilo/wiki/URL_patterns'
35 35

  
36
def make_hash_key(file_contents):
37
    return f'sha256-{sha256(file_contents.encode()).digest().hex()}'
38

  
39 36
def sample_file(contents):
40 37
    return {
41
        'hash_key': make_hash_key(contents),
38
        'sha256': sha256(contents.encode()).digest().hex(),
42 39
        'contents': contents
43 40
    }
44 41

  
......
51 48
    sample_files = dict([(name, sample_file(contents))
52 49
                         for name, contents in names_contents.items()])
53 50

  
54
    sample_files_by_hash = dict([[file['hash_key'], file['contents']]
55
                                 for file in sample_files.values()])
51
    sample_files_by_sha256 = dict([[file['sha256'], file['contents']]
52
                                   for file in sample_files.values()])
56 53

  
57
    return sample_files, sample_files_by_hash
54
    return sample_files, sample_files_by_sha256
58 55

  
59
sample_files, sample_files_by_hash = make_sample_files({
56
sample_files, sample_files_by_sha256 = make_sample_files({
60 57
    'report.spdx':              '<!-- dummy report -->',
61 58
    'LICENSES/somelicense.txt': 'Permission is granted...',
62 59
    'LICENSES/CC0-1.0.txt':     'Dummy Commons...',
......
73 70
    """
74 71
    return {
75 72
        'file': file_name,
76
        'hash_key': sample_files_dict[file_name]['hash_key']
73
        'sha256': sample_files_dict[file_name]['sha256']
77 74
    }
78 75

  
79 76
def make_sample_mapping(with_files=True):
......
154 151
    return {
155 152
        'resources': sample_data_dict([make_sample_resource()]),
156 153
        'mappings': sample_data_dict([make_sample_mapping()]),
157
        'files': sample_files_by_hash
154
        'file': {
155
            'sha256': sample_files_by_sha256
156
        }
158 157
    }
159 158

  
160 159
def clear_indexeddb(execute_in_page):

Also available in: Unified diff