diff options
author | Mikhail Elovskikh <wronglink@gmail.com> | 2019-01-04 03:27:47 +0500 |
---|---|---|
committer | Irina Truong <i.chernyavska@gmail.com> | 2019-01-03 14:27:47 -0800 |
commit | f614cef7ed63fd7f2a9c44600f4d3c84f96c59d2 (patch) | |
tree | c4c40d5f70ae2c763532086a3d681eb64f29d82f /tests/test_main.py | |
parent | a7650887bf9579ae71d0b100d62978132aabb5d1 (diff) |
Support multihost connection string (#978)
* Switch to psycopg2 parse_dsn instead of urlparse
* Added wronglink to contributors and updated changelog
* Fix test codestyle
* Support for PGPORT customization in tests
* Support for PGPORT customization in tests
* Refactored PGExecute init and moved short_host generation to object property
* Fix test util codestyle
* Fix local tests run
* Store PGExecute initial params in _conn_params and added PGExecute.copy method
* Fix codestyle
* Added docstring to PGExecute.copy() method
Diffstat (limited to 'tests/test_main.py')
-rw-r--r-- | tests/test_main.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test_main.py b/tests/test_main.py index fc4de7d9..b1c40356 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -267,7 +267,6 @@ def test_quoted_db_uri(tmpdir): cli = PGCli(pgclirc_file=str(tmpdir.join("rcfile"))) cli.connect_uri('postgres://bar%5E:%5Dfoo@baz.com/testdb%5B') mock_connect.assert_called_with(database='testdb[', - port=None, host='baz.com', user='bar^', passwd=']foo') @@ -281,7 +280,6 @@ def test_ssl_db_uri(tmpdir): 'sslmode=verify-full&sslcert=m%79.pem&sslkey=my-key.pem&sslrootcert=c%61.pem') mock_connect.assert_called_with(database='testdb[', host='baz.com', - port=None, user='bar^', passwd=']foo', sslmode='verify-full', @@ -299,3 +297,15 @@ def test_port_db_uri(tmpdir): user='bar', passwd='foo', port='2543') + + +def test_multihost_db_uri(tmpdir): + with mock.patch.object(PGCli, 'connect') as mock_connect: + cli = PGCli(pgclirc_file=str(tmpdir.join("rcfile"))) + cli.connect_uri( + 'postgres://bar:foo@baz1.com:2543,baz2.com:2543,baz3.com:2543/testdb') + mock_connect.assert_called_with(database='testdb', + host='baz1.com,baz2.com,baz3.com', + user='bar', + passwd='foo', + port='2543,2543,2543') |