Exemple #1
0
def test_default_expectations():
    expect_config_type = define_expectations_config_cls('some_name').inst()
    assert (ExpectationsConfig(
        **throwing_evaluate_config_value(expect_config_type, {})).evaluate is
            True)
    assert (ExpectationsConfig(
        **throwing_evaluate_config_value(expect_config_type, None)).evaluate is
            True)
Exemple #2
0
def test_expectations_config():
    expectations_config_type = define_expectations_config_cls('ksjdfkd').inst()
    expectations = ExpectationsConfig(**throwing_evaluate_config_value(
        expectations_config_type, {'evaluate': True}))

    assert isinstance(expectations, ExpectationsConfig)
    assert expectations.evaluate is True

    assert ExpectationsConfig(**throwing_evaluate_config_value(
        expectations_config_type, {'evaluate': False})) == ExpectationsConfig(
            evaluate=False)
Exemple #3
0
def test_whole_environment():
    pipeline_def = PipelineDefinition(
        name='some_pipeline',
        mode_definitions=[
            ModeDefinition(
                name='test_mode',
                resources={
                    'test_resource':
                    ResourceDefinition(resource_fn=lambda: None,
                                       config_field=Field(Any))
                },
            )
        ],
        solid_defs=[
            SolidDefinition(
                name='int_config_solid',
                config_field=Field(Int),
                inputs=[],
                outputs=[],
                compute_fn=lambda *args: None,
            ),
            SolidDefinition(name='no_config_solid',
                            inputs=[],
                            outputs=[],
                            compute_fn=lambda *args: None),
        ],
    )

    environment_type = create_environment_type(pipeline_def)

    assert (environment_type.fields['resources'].config_type.name ==
            'SomePipeline.Mode.TestMode.Resources')
    solids_type = environment_type.fields['solids'].config_type
    assert solids_type.name == 'SomePipeline.SolidsConfigDictionary'
    assert (solids_type.fields['int_config_solid'].config_type.name ==
            'SomePipeline.SolidConfig.IntConfigSolid')
    assert (environment_type.fields['expectations'].config_type.name ==
            'SomePipeline.ExpectationsConfig')

    env = EnvironmentConfig.from_dict(
        throwing_evaluate_config_value(
            environment_type,
            {
                'resources': {
                    'test_resource': {
                        'config': 1
                    }
                },
                'solids': {
                    'int_config_solid': {
                        'config': 123
                    }
                },
            },
        ))

    assert isinstance(env, EnvironmentConfig)
    assert env.solids == {'int_config_solid': SolidConfig(123)}
    assert env.expectations == ExpectationsConfig(evaluate=True)
    assert env.resources == {'test_resource': {'config': 1}}
def construct_environment_config(config_value):
    check.dict_param(config_value, 'config_value')
    return EnvironmentConfig(
        solids=construct_solid_dictionary(config_value['solids']),
        execution=ExecutionConfig(**config_value['execution']),
        expectations=ExpectationsConfig(**config_value['expectations']),
        context=construct_context_config(config_value['context']),
        original_config_dict=config_value,
    )
Exemple #5
0
def test_whole_environment():
    pipeline_def = PipelineDefinition(
        name='some_pipeline',
        context_definitions={
            'test':
            PipelineContextDefinition(
                config_field=Field(Any),
                context_fn=lambda *args: ExecutionContext())
        },
        solids=[
            SolidDefinition(
                name='int_config_solid',
                config_field=Field(Int),
                inputs=[],
                outputs=[],
                transform_fn=lambda *args: None,
            ),
            SolidDefinition(name='no_config_solid',
                            inputs=[],
                            outputs=[],
                            transform_fn=lambda *args: None),
        ],
    )

    environment_type = pipeline_def.environment_type

    assert environment_type.fields[
        'context'].config_type.name == 'SomePipeline.ContextConfig'
    solids_type = environment_type.fields['solids'].config_type
    assert solids_type.name == 'SomePipeline.SolidsConfigDictionary'
    assert (solids_type.fields['int_config_solid'].config_type.name ==
            'SomePipeline.SolidConfig.IntConfigSolid')
    assert (environment_type.fields['expectations'].config_type.name ==
            'SomePipeline.ExpectationsConfig')

    env = construct_environment_config(
        throwing_evaluate_config_value(
            pipeline_def.environment_type,
            {
                'context': {
                    'test': {
                        'config': 1
                    }
                },
                'solids': {
                    'int_config_solid': {
                        'config': 123
                    }
                }
            },
        ))

    assert isinstance(env, EnvironmentConfig)
    assert env.context == ContextConfig('test', 1, persistence={'file': {}})
    assert env.solids == {'int_config_solid': SolidConfig(123)}
    assert env.expectations == ExpectationsConfig(evaluate=True)