Example #1
0
def test_get_env_databag_parent():
    """processes top .env directory"""
    data = api.get_env_databag(root_dir, True, None)
    assert data.get("parent_value") == "top"
    assert api.get_output_databag_filename() == os.path.join(
        root_dir,
        constants.ENV_DIR,
        "output_databag.yaml"
    )
    assert data.get("env_name") is None
Example #2
0
def test_get_env_databag_output():
    """must read from output_databag.yaml and munge parents"""
    data = api.get_env_databag(root_dir, True, "prod")
    assert data.get("prod_value") == "prod"
    assert data.get("common_value") == "common"
    assert api.get_output_databag_filename() == os.path.join(
        root_dir,
        constants.ENV_DIR,
        "prod/output_databag.yaml"
    )
    assert data.get("env_name") == "prod"
Example #3
0
def test_deep_nested_env_no_merge_databag():
    """merge flag is honored"""
    data = api.get_env_databag(root_dir, False, "dev/special")
    logger.debug(data)
    assert data.get("new_value") is None
    assert data.get("common_value") is None
    assert data.get("special_value") == "special"
    assert api.get_output_databag_filename() == os.path.join(
        root_dir,
        constants.ENV_DIR,
        "dev/special/output_databag.yaml"
    )
Example #4
0
def test_get_env_databag_child():
    """processes first child env"""
    data = api.get_env_databag(root_dir, True, "dev")
    assert data.get("new_value") == "new"
    assert data.get("parent_value") == "override"
    assert data.get("common_value") == "common"
    assert api.get_output_databag_filename() == os.path.join(
        root_dir,
        constants.ENV_DIR,
        "dev/output_databag.yaml"
    )
    assert data.get("env_name") == "dev"
Example #5
0
def test_deep_nested_env_databag():
    """processes 2 level env hierarchy"""
    data = api.get_env_databag(root_dir, True, "dev/special")
    assert data.get("new_value") == "new"
    assert data.get("parent_value") == "override"
    assert data.get("common_value") == "common"
    assert data.get("special_value") == "special"
    assert api.get_output_databag_filename() == os.path.join(
        root_dir,
        constants.ENV_DIR,
        "dev/special/output_databag.yaml"
    )
    assert data.get("env_name") == "dev/special"
Example #6
0
def test_databag_init_ok():
    """stale databag values must be updated with per-run settings"""
    data = api.get_env_databag(root_dir, False, "dev/special")

    assert data.get("intermediate_databag_file") is not None
    assert data.get("intermediate_databag_file") != "stale"
Example #7
0
def test_databag_default_values():
    """default values must be loaded"""
    data = api.get_env_databag(root_dir, False, "dev/special")

    assert data.get("up_verb") == constants.UP_VERB
Example #8
0
def test_get_env_databag_raises():
    """Raise if there are too many directories to process"""
    with pytest.raises(RuntimeError):
        _ = api.get_env_databag(root_dir, True, "1/2/3/4/5")