コード例 #1
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def test_call_with_config(caplog, _jail):
    """Test call using a config file with substeps

    In particular, from JP-1482, there was a case where a substep parameter
    was not being overridden. Test for that case.
    """
    cfg = t_path(join('data', 'proper_pipeline.asdf'))
    model = t_path(join('data', 'flat.fits'))

    ProperPipeline.call(model, config_file=cfg)

    assert "'par1': 'newpar1'" in caplog.text
コード例 #2
0
def test_makeliststep_call_from_within_pipeline():
    """Test override step asdf with .cfg"""
    config_file = t_path(
        Path('steps') / 'makelist_pipeline.cfg'
    )
    results = MakeListPipeline.call(config_file=config_file)
    assert results == [43.0, 'My hovercraft is full of eels.', False]
コード例 #3
0
def test_step_from_asdf_api_override():
    """Test initializing step completely from config"""
    config_file = t_path(
        Path('steps') / 'jwst_generic_pars-makeliststep_0001.asdf'
    )
    results = MakeListStep.call(config_file=config_file, par1=0.)
    assert results == [0., DEFAULT_PAR2, False]
コード例 #4
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_input_dir_with_model(mk_tmp_dirs):
    """Use with an already opened DataModel"""
    with datamodels.open(t_path('data/flat.fits')) as model:
        step = StepWithModel()
        step.run(model)

        assert step.input_dir == ''
コード例 #5
0
def test_asdf_from_call():
    """Test using an ASDF file from call"""
    config_file = t_path(
        Path('steps') / 'jwst_generic_pars-makeliststep_0001.asdf'
    )
    results = MakeListStep.call(config_file=config_file)

    assert results == DEFAULT_RESULT
コード例 #6
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_default_input_with_full_model():
    """Test default input name retrieval with actual model"""
    model_path = t_path('data/flat.fits')
    with datamodels.open(model_path) as model:
        step = StepWithModel()
        step.run(model)

        assert step._input_filename == model.meta.filename
コード例 #7
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_default_input_with_container(mk_tmp_dirs):
    """Test default input name from a ModelContainer"""

    model_path = t_path('data/flat.fits')
    with ModelContainer([model_path]) as container:
        step = StepWithModel()
        step.run(container)

        assert step._input_filename is None
コード例 #8
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_default_input_dir(mk_tmp_dirs):
    """Test defaults"""
    input_file = t_path('data/flat.fits')

    step = Step.from_cmdline(
        ['jwst.stpipe.tests.steps.StepWithModel', input_file])

    # Check that `input_dir` is set.
    input_path = path.split(input_file)[0]
    assert step.input_dir == input_path
コード例 #9
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def test_saving_pars(tmpdir):
    """Save the step parameters from the commandline"""
    cfg_path = t_path(join('steps', 'jwst_generic_pars-makeliststep_0002.asdf'))
    saved_path = tmpdir.join('savepars.asdf')
    step = Step.from_cmdline([
        cfg_path,
        '--save-parameters',
        str(saved_path)
    ])
    assert saved_path.check()

    with asdf.open(t_path(join('steps', 'jwst_generic_pars-makeliststep_0002.asdf'))) as af:
        original_config = StepConfig.from_asdf(af)
        original_config.parameters["par3"] = False

    with asdf.open(str(saved_path)) as af:
        config = StepConfig.from_asdf(af)
        assert config.parameters == original_config.parameters

    step.closeout()
コード例 #10
0
def test_step_from_asdf():
    """Test initializing step completely from config"""
    config_file = t_path(
        Path('steps') / 'jwst_generic_pars-makeliststep_0001.asdf'
    )
    step = Step.from_config_file(config_file)
    assert isinstance(step, MakeListStep)
    assert step.name == 'make_list'

    results = step.run()
    assert results == DEFAULT_RESULT
コード例 #11
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_set_input_dir(mk_tmp_dirs):
    """Simply set the path"""
    input_file = t_path('data/flat.fits')

    step = Step.from_cmdline([
        'jwst.stpipe.tests.steps.StepWithModel', input_file, '--input_dir',
        'junkdir'
    ])

    # Check that `input_dir` is set.
    assert step.input_dir == 'junkdir'
コード例 #12
0
def test_step_from_asdf_noname():
    """Test initializing step completely from config without a name specified"""
    root = 'jwst_generic_pars-makeliststep_0002'
    config_file = t_path(
        Path('steps') / (root + '.asdf')
    )
    step = Step.from_config_file(config_file)
    assert isinstance(step, MakeListStep)
    assert step.name == root

    results = step.run()
    assert results == DEFAULT_RESULT
コード例 #13
0
ファイル: test_input.py プロジェクト: spacetelescope/jwst
def test_use_input_dir(mk_tmp_dirs):
    """Test with a specified path"""
    input_dir = t_path('data')
    input_file = 'flat.fits'

    step = Step.from_cmdline([
        'jwst.stpipe.tests.steps.StepWithModel', input_file, '--input_dir',
        input_dir
    ])

    # Check that `input_dir` is set.
    assert step.input_dir == input_dir
コード例 #14
0
def test_from_command_line_override():
    """Test creating Step from command line using ASDF"""
    config_file = t_path(
        Path('steps') / 'jwst_generic_pars-makeliststep_0001.asdf'
    )
    args = [config_file, '--par1=0.']
    step = Step.from_cmdline(args)
    assert isinstance(step, MakeListStep)
    assert step.par1 == 0.
    assert step.par2 == 'Yes, a string'

    results = step.run()
    assert results == [0., DEFAULT_PAR2, False]
コード例 #15
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def data_path():
    """Provide a test data model"""
    data_path = t_path(join('data', 'miri_data.fits'))
    return data_path
コード例 #16
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def test_reftype(cfg_file, expected_reftype):
    """Test that reftype is produced as expected"""
    step = Step.from_config_file(t_path(join('steps', cfg_file)))
    assert step.__class__.get_config_reftype() == expected_reftype
    assert step.get_config_reftype() == expected_reftype
コード例 #17
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def test_parameters_from_crds():
    """Test retrieval of parameters from CRDS"""
    step_class = REFPIXSTEP_CRDS_MIRI_PARS['class']
    data = datamodels.open(t_path(join('data', 'miri_data.fits')))
    pars = step_class.get_config_from_reference(data)
    assert pars == REFPIXSTEP_CRDS_MIRI_PARS
コード例 #18
0
ファイル: test_step.py プロジェクト: spacetelescope/jwst
def test_parameters_from_crds_fail():
    """Test retrieval of parameters from CRDS"""
    with datamodels.open(t_path(join('data', 'miri_data.fits'))) as data:
        data.meta.instrument.name = 'NIRSPEC'
        pars = RefPixStep.get_config_from_reference(data)
        assert not len(pars)
コード例 #19
0
def test_parameters_from_crds():
    """Test retrieval of parameters from CRDS"""
    with datamodels.open(t_path(join('data', 'miri_data.fits'))) as data:
        pars = WhiteLightStep.get_config_from_reference(data)
    assert pars == WHITELIGHTSTEP_CRDS_MIRI_PARS