diff --git a/jwst/associations/tests/test_level3_product_names.py b/jwst/associations/tests/test_level3_product_names.py index 1da85ce9a6b..74213b024b4 100644 --- a/jwst/associations/tests/test_level3_product_names.py +++ b/jwst/associations/tests/test_level3_product_names.py @@ -96,7 +96,7 @@ def test_level3_names(pool_file, global_constraints): rules = registry_level3_only( global_constraints=global_constraints ) - pool = AssociationPool.read(pool_file) + pool = combine_pools(pool_file) asns = generate(pool, rules) for asn in asns: product_name = asn['products'][0]['name'] @@ -110,8 +110,8 @@ def test_level3_names(pool_file, global_constraints): def test_multiple_optelems(pool_file): rules = registry_level3_only() - pool = AssociationPool.read(pool_file) - asns = generate(pool, rules) + pool = combine_pools(pool_file) + asns = generate(pool, rules, finalize=False) for asn in asns: product_name = asn['products'][0]['name'] if asn['asn_rule'] != 'Asn_Lv3MIRMRS': @@ -137,7 +137,37 @@ def test_multiple_optelems(pool_file): value = '-'.join(asn.constraints[extra].found_values) except KeyError: value = None - if value not in EMPTY: + + # empty values and subarray = full are not recorded + if value not in EMPTY and value != 'full': values.append(value) assert m.groupdict()['opt_elem'] == '-'.join(values) + + +def test_tso3_names(): + rules = registry_level3_only() + tso_pool = t_path('data/pool_021_tso.csv') + pool = combine_pools(tso_pool) + asns = generate(pool, rules, finalize=False) + for asn in asns: + product_name = asn['products'][0]['name'] + + m = re.match(LEVEL3_PRODUCT_NAME_REGEX, product_name) + assert m is not None + + # there should always be an opt_elem + values = ['-'.join(asn.constraints['opt_elem'].found_values)] + + # there may also be an opt_elem2, fixed slit or 2, or a subarray + for extra in ['opt_elem2', 'fxd_slit', 'fxd_slit2', 'subarray']: + try: + value = '-'.join(asn.constraints[extra].found_values) + except KeyError: + value = None + + # empty values and subarray = full are not recorded + if value not in EMPTY and value != 'full': + values.append(value) + + assert m.groupdict()['opt_elem'] == '-'.join(values)