@@ -332,6 +332,8 @@ def verify_output(self, history_id, jobs, output_data, output_testdef, tool_id,
332332 attributes = output_testdef .attributes
333333 name = output_testdef .name
334334 expected_count = attributes .get ("count" )
335+ min_count = attributes .get ("min" )
336+ max_count = attributes .get ("max" )
335337 hid = self .__output_id (output_data )
336338 # TODO: Twill version verifies dataset is 'ok' in here.
337339 try :
@@ -357,6 +359,14 @@ def verify_output(self, history_id, jobs, output_data, output_testdef, tool_id,
357359 raise AssertionError (
358360 f"Output '{ name } ': expected to have '{ expected_count } ' datasets, but it had '{ found_datasets } '"
359361 )
362+ if min_count is not None and min_count > found_datasets :
363+ raise AssertionError (
364+ f"Output '{ name } ': expected to have at least '{ min_count } ' datasets, but it had '{ found_datasets } '"
365+ )
366+ if max_count is not None and max_count < found_datasets :
367+ raise AssertionError (
368+ f"Output '{ name } ': expected to have at most '{ max_count } ' datasets, but it had '{ found_datasets } '"
369+ )
360370 for designation , (primary_outfile , primary_attributes ) in primary_datasets .items ():
361371 primary_output = None
362372 for output in outputs :
@@ -1335,12 +1345,16 @@ def verify_collection(output_collection_def, data_collection, verify_dataset):
13351345 message = f"Output collection '{ name } ': expected to be of type [{ expected_collection_type } ], was of type [{ collection_type } ]."
13361346 raise AssertionError (message )
13371347
1338- expected_element_count = output_collection_def .count
1339- if expected_element_count is not None :
1340- actual_element_count = len (data_collection ["elements" ])
1341- if expected_element_count != actual_element_count :
1342- message = f"Output collection '{ name } ': expected to have { expected_element_count } elements, but it had { actual_element_count } ."
1343- raise AssertionError (message )
1348+ actual_element_count = len (data_collection ["elements" ])
1349+ if output_collection_def .count and output_collection_def .count != actual_element_count :
1350+ message = f"Output collection '{ name } ': expected to have { output_collection_def .count } elements, but it had { actual_element_count } ."
1351+ raise AssertionError (message )
1352+ if output_collection_def .min and output_collection_def .min > actual_element_count :
1353+ message = f"Output collection '{ name } ': expected to have at least { output_collection_def .min } elements, but it had { actual_element_count } ."
1354+ raise AssertionError (message )
1355+ if output_collection_def .max and output_collection_def .max < actual_element_count :
1356+ message = f"Output collection '{ name } ': expected to have at most { output_collection_def .max } elements, but it had { actual_element_count } ."
1357+ raise AssertionError (message )
13441358
13451359 def get_element (elements , id ):
13461360 for element in elements :
@@ -1356,7 +1370,6 @@ def verify_elements(element_objects, element_tests):
13561370 element_outfile , element_attrib = None , element_test
13571371 else :
13581372 element_outfile , element_attrib = element_test
1359- expected_count = element_attrib .get ("count" )
13601373 if "expected_sort_order" in element_attrib :
13611374 expected_sort_order [element_attrib ["expected_sort_order" ]] = element_identifier
13621375
@@ -1373,10 +1386,21 @@ def verify_elements(element_objects, element_tests):
13731386 elements = element ["object" ]["elements" ]
13741387 element_count = len (elements )
13751388 verify_elements (elements , element_attrib .get ("elements" , {}))
1389+ expected_count = element_attrib .get ("count" )
13761390 if expected_count is not None and expected_count != element_count :
13771391 raise AssertionError (
13781392 f"Element '{ element_identifier } ': expected to have { expected_count } elements, but it had { element_count } "
13791393 )
1394+ max = element_attrib .get ("max" )
1395+ if max is not None and max < element_count :
1396+ raise AssertionError (
1397+ f"Element '{ element_identifier } ': expected to have at most { max } elements, but it had { element_count } "
1398+ )
1399+ min = element_attrib .get ("min" )
1400+ if min is not None and min > element_count :
1401+ raise AssertionError (
1402+ f"Element '{ element_identifier } ': expected to have at least { min } elements, but it had { element_count } "
1403+ )
13801404
13811405 if len (expected_sort_order ) > 0 :
13821406 generated_sort_order = [_ ["element_identifier" ] for _ in element_objects ]
0 commit comments