@@ -174,10 +174,12 @@ def test_check_type_of_param_value_sanity_check_paths(self):
174174 def test_check_type_of_param_value_checksums (self ):
175175 """Test check_type_of_param_value function for checksums."""
176176
177- md5_checksum = 'fa618be8435447a017fd1bf2c7ae9224'
178- sha256_checksum1 = 'fa618be8435447a017fd1bf2c7ae922d0428056cfc7449f7a8641edf76b48265'
179- sha256_checksum2 = 'b5f9cb06105c1d2d30719db5ffb3ea67da60919fb68deaefa583deccd8813551'
180- sha256_checksum3 = '033be54514a03e255df75c5aee8f9e672f663f93abb723444caec8fe43437bde'
177+ # Using (actually invalid) prefix to better detect those in case of errors
178+ md5_checksum = 'md518be8435447a017fd1bf2c7ae9224'
179+ sha256_checksum1 = 'sha18be8435447a017fd1bf2c7ae922d0428056cfc7449f7a8641edf76b48265'
180+ sha256_checksum2 = 'sha2cb06105c1d2d30719db5ffb3ea67da60919fb68deaefa583deccd8813551'
181+ sha256_checksum3 = 'sha3e54514a03e255df75c5aee8f9e672f663f93abb723444caec8fe43437bde'
182+ filesize = 45617379
181183
182184 # valid values for 'checksums' easyconfig parameters
183185 inputs = [
@@ -190,6 +192,7 @@ def test_check_type_of_param_value_checksums(self):
190192 # one checksum of specific type (as 2-tuple)
191193 [('md5' , md5_checksum )],
192194 [('sha256' , sha256_checksum1 )],
195+ [('size' , filesize )],
193196 # alternative checksums for a single file (n-tuple)
194197 [(sha256_checksum1 , sha256_checksum2 )],
195198 [(sha256_checksum1 , sha256_checksum2 , sha256_checksum3 )],
@@ -213,17 +216,33 @@ def test_check_type_of_param_value_checksums(self):
213216 # two checksums for a single file, *both* should match
214217 [sha256_checksum1 , md5_checksum ],
215218 # three checksums for a single file, *all* should match
216- [sha256_checksum1 , ('md5' , md5_checksum ), { 'foo.txt' : sha256_checksum1 } ],
219+ [sha256_checksum1 , ('md5' , md5_checksum ), ( 'size' , filesize ) ],
217220 # single checksum for a single file
218221 sha256_checksum1 ,
219222 # filename-to-checksum mapping
220- {'foo.txt' : sha256_checksum1 , 'bar.txt' : sha256_checksum2 },
223+ {'foo.txt' : sha256_checksum1 , 'bar.txt' : sha256_checksum2 , 'baz.txt' : ( 'size' , filesize ) },
221224 # 3 alternative checksums for a single file, one match is sufficient
222225 (sha256_checksum1 , sha256_checksum2 , sha256_checksum3 ),
223- ]
226+ # two alternative checksums for a single file (not to be confused by checksum-type & -value tuple)
227+ (sha256_checksum1 , md5_checksum ),
228+ # three alternative checksums for a single file of different types
229+ (sha256_checksum1 , ('md5' , md5_checksum ), ('size' , filesize )),
230+ # alternative checksums in dicts are also allowed
231+ {'foo.txt' : (sha256_checksum2 , sha256_checksum3 ), 'bar.txt' : (sha256_checksum1 , md5_checksum )},
232+ # Same but with lists -> all must match for each file
233+ {'foo.txt' : [sha256_checksum2 , sha256_checksum3 ], 'bar.txt' : [sha256_checksum1 , md5_checksum ]},
234+ ],
235+ # None is allowed, meaning skip the checksum
236+ [
237+ None ,
238+ # Also in mappings
239+ {'foo.txt' : sha256_checksum1 , 'bar.txt' : None },
240+ ],
224241 ]
225242 for inp in inputs :
226- self .assertEqual (check_type_of_param_value ('checksums' , inp ), (True , inp ))
243+ type_ok , newval = check_type_of_param_value ('checksums' , inp )
244+ self .assertIs (type_ok , True , 'Failed for ' + str (inp ))
245+ self .assertEqual (newval , inp )
227246
228247 def test_check_type_of_param_value_patches (self ):
229248 """Test check_type_of_param_value function for patches."""
0 commit comments