Skip to content

Commit

Permalink
added a test for invariant filename
Browse files Browse the repository at this point in the history
  • Loading branch information
jemorrison committed Dec 16, 2024
1 parent 364b55f commit 0069f17
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions jwst/stpipe/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from jwst.stpipe.utilities import all_steps, NOT_SET
import jwst.pipeline
import jwst.step
import pytest
from stdatamodels.jwst import datamodels
from jwst.stpipe.utilities import invariant_filename

from jwst import datamodels as dm


Expand Down Expand Up @@ -54,3 +58,32 @@ def test_record_query_step_status():
# test query not set
model3 = dm.MultiSpecModel()
assert query_step_status(model3, 'test_step') == NOT_SET

# make up a datamodel for testing filename
@pytest.fixture(scope='function')
def miri_ifushort():
""" Generate input model IFU image """


mirifushort_short = {
'detector': 'MIRIFUSHORT',
'channel': '12',
'band': 'SHORT',
'name': 'MIRI'

}
input_model = datamodels.IFUImageModel()
input_model.meta.exposure.type = 'MIR_MRS'
input_model.meta.instrument._instance.update(mirifushort_short)
input_model.meta.filename = 'test1.fits'
return input_model


def change_name_func(model):
model.meta.filename = "changed"
return model

def test_invariant_filename(miri_ifushort):
invariant_save_func = invariant_filename(change_name_func)
output_model = invariant_save_func(miri_ifushort)
assert output_model.meta.filename == "test1.fits"

0 comments on commit 0069f17

Please sign in to comment.