Example #1
0
def test_merge():
    base_preset = PresetDefinition(
        "base",
        run_config={
            "context": {
                "unittest": {
                    "resources": {
                        "db_resource": {
                            "config": {
                                "user": "******",
                                "password": "******"
                            }
                        }
                    }
                }
            }
        },
    )

    new_preset = base_preset.with_additional_config({
        "context": {
            "unittest": {
                "resources": {
                    "another": {
                        "config": "not_sensitive"
                    }
                }
            }
        }
    })

    assert new_preset.run_config == {
        "context": {
            "unittest": {
                "resources": {
                    "db_resource": {
                        "config": {
                            "user": "******",
                            "password": "******"
                        }
                    },
                    "another": {
                        "config": "not_sensitive"
                    },
                }
            }
        }
    }
Example #2
0
def test_with_additional_config(initial_run_config):
    # Given: an initial preset with a run config or no run config
    preset_def = PresetDefinition("example_with_config",
                                  run_config=initial_run_config)

    # And: new config to be added
    new_config = {"fizz": "buzz"}

    # When: additional config is added
    new_preset_def = preset_def.with_additional_config(new_config)

    # Then: the new preset is a new preset object
    assert id(preset_def) != id(new_preset_def)

    # And: the preset has the expected new config
    new_full_config = {
        "foo": "bar",
        "fizz": "buzz"
    } if initial_run_config else new_config
    assert new_preset_def == PresetDefinition("example_with_config",
                                              run_config=new_full_config)