Skip to content

Commit

Permalink
Merge pull request #5 from boegel/checksums-itemdict
Browse files Browse the repository at this point in the history
each entry in checksums may in turn be a list of different types of checksums
  • Loading branch information
edmondac authored Aug 12, 2019
2 parents 530982b + 3c8f196 commit 03626a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions easybuild/framework/easyconfig/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,12 @@ def ensure_iterable_license_specs(specs):
# each entry can be:
# a single checksum value (string)
# a single checksum value of a specified type (2-tuple, 1st element is checksum type, 2nd element is checksum)
# a list of checksums (of different types) as string values, which should *all* be valid
# a list of checksums (of different types, perhaps different formats), which should *all* be valid
# a dictionary with a mapping from filename to checksum value
CHECKSUMS = (list, as_hashable({'elem_types': [str, tuple, LIST_OF_STRINGS, STRING_DICT]}))
CHECKSUM_LIST = (list, as_hashable({'elem_types': [str, tuple, STRING_DICT]}))
CHECKSUMS = (list, as_hashable({'elem_types': [str, tuple, STRING_DICT, CHECKSUM_LIST]}))

CHECKABLE_TYPES = [CHECKSUMS, DEPENDENCIES, DEPENDENCY_DICT, LIST_OF_STRINGS,
CHECKABLE_TYPES = [CHECKSUM_LIST, CHECKSUMS, DEPENDENCIES, DEPENDENCY_DICT, LIST_OF_STRINGS,
SANITY_CHECK_PATHS_DICT, STRING_DICT, STRING_OR_TUPLE_LIST, TOOLCHAIN_DICT, TUPLE_OF_STRINGS]

# easy types, that can be verified with isinstance
Expand Down
6 changes: 6 additions & 0 deletions test/framework/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def test_check_type_of_param_value_checksums(self):
('md5', md5_checksum),
{'foo.txt': sha256_checksum2, 'bar.txt': sha256_checksum3},
],
# each item can be a list of checksums for a single file, which can be of different types...
[
[sha256_checksum1, sha256_checksum2, sha256_checksum3],
[sha256_checksum1, ('md5', md5_checksum), {'foo.txt': sha256_checksum2}],
[sha256_checksum1],
]
]
for inp in inputs:
self.assertEqual(check_type_of_param_value('checksums', inp), (True, inp))
Expand Down

0 comments on commit 03626a3

Please sign in to comment.