-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle database URLs a bit better (#1575)
* Add url-splitting pseudo option handlers to config. * Update whats_new.rst * Mypyage * Lintage * Fix tests for new behaviour.
- Loading branch information
1 parent
e318d1f
commit 93e1d01
Showing
3 changed files
with
61 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,8 +213,9 @@ def test_single_env(single_env_config): | |
|
||
assert cfg['experimental'].index_driver == "postgis" | ||
assert cfg['experimental'].db_url == "postgresql://foo:[email protected]/mytestdb" | ||
assert cfg['experimental'].db_username == "foo" | ||
with pytest.raises(AttributeError): | ||
assert cfg['experimental'].db_username | ||
assert cfg['experimental'].not_an_option | ||
assert cfg['experimental']['db_iam_authentication'] | ||
assert cfg['experimental'].db_iam_timeout == 600 | ||
assert cfg['experimental']['db_connection_timeout'] == 60 | ||
|
@@ -257,8 +258,9 @@ def assert_simple_options(cfg): | |
assert cfg['default']["db_iam_timeout"] | ||
|
||
assert cfg['exp2'].db_url == "postgresql://foo:[email protected]/mytestdb" | ||
assert cfg['exp2'].db_username == "foo" | ||
with pytest.raises(AttributeError): | ||
assert cfg['exp2'].db_username | ||
assert cfg['exp2'].not_an_option | ||
assert cfg['exp2']['db_iam_authentication'] | ||
assert cfg['exp2'].db_iam_timeout == 300 | ||
assert cfg['exp2']['db_connection_timeout'] == 60 | ||
|
@@ -284,8 +286,7 @@ def test_noenv_overrides_in_text(simple_config, monkeypatch): | |
cfg = ODCConfig(text=simple_config) | ||
|
||
assert cfg["legacy"].db_username != 'bar' | ||
with pytest.raises(AttributeError): | ||
cfg["experimental"].db_username | ||
assert cfg["experimental"].db_username != "bar" | ||
|
||
|
||
@pytest.fixture | ||
|
@@ -389,8 +390,7 @@ def test_envvar_overrides(path_to_yaml_config, monkeypatch): | |
assert cfg["experimental"].db_iam_authentication | ||
assert cfg["exp2"].db_iam_authentication | ||
assert cfg["exp2"].db_connection_timeout == 20 | ||
with pytest.raises(AttributeError): | ||
assert cfg["experimental"].db_username == 'bar' | ||
assert cfg["experimental"].db_username != 'bar' | ||
|
||
|
||
def test_intopt_validation(): | ||
|
@@ -467,6 +467,12 @@ def test_pgurl_from_config(simple_dict): | |
psql_url_from_config( | ||
cfg["memory"] | ||
) | ||
assert cfg["exp2"].db_url == "postgresql://foo:[email protected]/mytestdb" | ||
assert cfg["exp2"].db_username == "foo" | ||
assert cfg["exp2"].db_password == "bar" | ||
assert cfg["exp2"].db_hostname == "server.subdomain.domain" | ||
assert not cfg["exp2"].db_port | ||
assert cfg["exp2"].db_database == "mytestdb" | ||
|
||
cfg = ODCConfig(raw_dict={ | ||
"foo": { | ||
|