Exemplo n.º 1
0
def test_makeliststep_call_config_file():
    """Test override step asdf with .cfg"""
    config_file = t_path(
        Path('steps') / 'makelist.cfg'
    )
    results = MakeListStep.call(config_file=config_file)
    assert results == [43.0, 'My hovercraft is full of eels.', False]
Exemplo n.º 2
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]
Exemplo n.º 3
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
Exemplo n.º 4
0
def test_load_config_file_s3(s3_root_dir):
    path = str(s3_root_dir.join("pars-makeliststep.asdf"))
    MakeListStep(par1=42.0, par2="foo").export_config(path)

    result = config_parser.load_config_file(
        "s3://test-s3-data/pars-makeliststep.asdf")
    assert isinstance(result, ConfigObj)

    with pytest.raises(ValueError):
        config_parser.load_config_file("s3://test-s3-data/missing.asdf")
Exemplo n.º 5
0
def test_load_config_file_s3(s3_root_dir):
    path = str(s3_root_dir.join("pars-makeliststep.asdf"))
    with MakeListStep.get_pars_model() as model:
        model.save(path)

    result = config_parser.load_config_file("s3://test-s3-data/pars-makeliststep.asdf")
    assert isinstance(result, ConfigObj)

    with pytest.raises(ValueError):
        config_parser.load_config_file("s3://test-s3-data/missing.asdf")
Exemplo n.º 6
0
    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()


@pytest.mark.parametrize(
    'step_obj, expected',
    [
        (
            MakeListStep(par1=0., par2='from args'),
            StepConfig(
                'jwst.stpipe.tests.steps.MakeListStep',
                'MakeListStep',
                {
                    'pre_hooks': [],
                    'post_hooks': [],
                    'output_ext': '.fits',
                    'output_use_model': False,
                    'output_use_index': True,
                    'save_results': False,
                    'skip': False,
                    'search_output_file': True,
                    'input_dir': '',
                    'par1': 0.0,
                    'par2': 'from args',
Exemplo n.º 7
0
def test_makeliststep_test():
    """Test the testing step class for basic operation"""
    result = MakeListStep.call(par1=DEFAULT_PAR1, par2=DEFAULT_PAR2)

    assert result == DEFAULT_RESULT
Exemplo n.º 8
0
def test_makeliststep_missingpars():
    """Test the testing step class when given insufficient information"""
    with pytest.raises(ValidationError):
        MakeListStep.call()