Skip to content

Commit

Permalink
Update tests to check more conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke committed Aug 9, 2024
1 parent 9c781b8 commit 542ec0e
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions jwst/associations/tests/test_level3_product_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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':
Expand All @@ -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)

0 comments on commit 542ec0e

Please sign in to comment.