summaryrefslogtreecommitdiffstats
path: root/tests/test_main.py
diff options
context:
space:
mode:
authorEric Wald <gitter@brainshell.org>2016-06-29 11:58:17 -0600
committerEric Wald <eswald@gmail.com>2016-06-29 16:59:42 -0600
commitae0fcab9c9c6f9b395f4d15d386e558291c762de (patch)
tree1a7ec3e4882d3802d540c2ab42de47accbde5ac1 /tests/test_main.py
parent04414098c2b5f46028171b5c4bcbe30ff902348a (diff)
Repair exception thrown on urls with ports
When the database URL contains a port, uri.port is (at least in Python 2.7.6) an integer, not a string, so urlparse.unquote chokes on it. Fixes issue #536, but is probably worth verifying on Python 3.
Diffstat (limited to 'tests/test_main.py')
-rw-r--r--tests/test_main.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_main.py b/tests/test_main.py
index cdf82ce3..ba11298c 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -90,3 +90,10 @@ 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('testdb[', 'baz.com', 'bar^', None, ']foo')
+
+
+def test_port_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@baz.com:2543/testdb')
+ mock_connect.assert_called_with('testdb', 'baz.com', 'bar', '2543', 'foo')