Esempio n. 1
0
def test_netpalm_config_honors_envvar():
    with pytest.raises(FileNotFoundError):
        config = confload.Config("DOES NOT EXIST.json")

    with pytest.raises(FileNotFoundError):
        os.environ["NETPALM_CONFIG"] = "DOES NOT EXIST.JSON"
        config = confload.initialize_config()

    # with pytest.raises(FileNotFoundError):  # this depends on the fact that you're running pytest from the tests directory
    #     del os.environ["NETPALM_CONFIG"]    # but we're not doing that anymore and it's okay really
    #     config = confload.initialize_config()

    config = confload.Config(ACTUAL_CONFIG_PATH)
    os.environ["NETPALM_CONFIG"] = str(ACTUAL_CONFIG_PATH)
    config = confload.initialize_config()
Esempio n. 2
0
def test_netpalm_config_value_precedence(monkeypatch):
    file_config = confload.Config(ACTUAL_CONFIG_PATH)
    monkeypatch.setenv("NETPALM_REDIS_SERVER", "123.COM")
    envvar_config = confload.Config(ACTUAL_CONFIG_PATH)
    assert file_config.redis_key == envvar_config.redis_key
    assert envvar_config.redis_server == '123.COM'