def test_with_missing_secret_key_in_vault(broker): broker.setup({ "data": {}, 'status_code': 200, }) with pytest.raises(SecretNotFoundError): envyconfig.load('fixtures/missing_key_vault.yaml')
def test_with_supplied_format_parameters(): formats = { 'interpolated': 'some_stuff', } config = envyconfig.load('fixtures/basic_format.yaml', override=formats) assert config['foo'] == 'This string will be some_stuff.' assert config['bar']['baz1'] == 'This string will also be some_stuff.'
def test_with_older_version_in_vault(broker): expected = '1235\n' broker.setup({ "data": { "foo_secret": expected }, 'version': 1, 'status_code': 200, }) config = envyconfig.load('fixtures/basic_vault.yaml') assert config['older_foo'] == expected
def test_that_we_duck_type_basic_defaults() -> None: config = envyconfig.load('fixtures/basic_env.yaml') typed = config['bar'] assert type(typed['baz1']) is bool assert not typed['baz1'] assert type(typed['baz2']) is bool assert typed['baz2'] assert type(typed['baz3']) is int assert typed['baz3'] == 1232 assert type(typed['baz4']) is float assert typed['baz4'] == 1232.2 assert type(typed['baz5']) is str assert typed['baz5'] == 'abcd'
def test_that_we_handle_missing_address_in_config(environment): environment.setenv("VAULT_ADDR", '') with pytest.raises(ConfigurationError): envyconfig.load('fixtures/basic_vault.yaml')
def test_multiple_colons(): config = envyconfig.load('fixtures/complex.yaml') assert config['foo'] is None
def test_nested(): config = envyconfig.load('fixtures/basic_nested.yaml') assert config['foo']['bar'] == 'baz'
def test_that_we_allow_missing_defaults() -> None: config = envyconfig.load('fixtures/basic_env.yaml') typed = config['bar'] assert typed['baz6'] is None
def test_empty_value(): config = envyconfig.load('fixtures/basic.yaml') assert config['baz'] == ''
def test_basic(): config = envyconfig.load('fixtures/basic.yaml') assert config['foo'] == 'bar'
def test_flattened(): config = envyconfig.load('fixtures/basic_nested.yaml', flatten=True) assert config['bar'] == 'baz'
def test_that_we_can_specify_a_secret_version(): config = envyconfig.load('fixtures/basic_gs.yaml') assert config['foo'] == 'projects/my-project/secrets/my-secret/versions/2'
def test_nested_gs(): config = envyconfig.load('fixtures/nested_gs.yaml') assert config['foo']['bar'] == 'projects/my-project/secrets/my-secret/versions/1'
def test_with_env_var(monkeypatch): expected = 'some string' monkeypatch.setenv("TESTENVVAR", expected) config = envyconfig.load('fixtures/basic_env.yaml') assert config['foo'] == expected
def test_use_default_when_env_var_is_not_defined(): config = envyconfig.load('fixtures/basic_env.yaml') assert config['foo'] == 'bar'