aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPablo Carranza <pcarranza@gmail.com>2017-06-10 22:34:56 +0000
committerPablo Carranza <pcarranza@gmail.com>2017-06-10 22:34:56 +0000
commiteb9060e520d5711367253b80fa17e47614b2408c (patch)
tree876a96bbc73c3bdedce64fabafcf466889756d48 /tests
parent7ea87dd5616e173fdf5dce2e030af051be79e2c9 (diff)
parent0a626be4cdc8eee651c008724559f338d47347c4 (diff)
downloadprometheus-pgbouncer-exporter-eb9060e520d5711367253b80fa17e47614b2408c.tar
prometheus-pgbouncer-exporter-eb9060e520d5711367253b80fa17e47614b2408c.tar.gz
Merge branch 'pc-add-password' into 'master'
Add password as an argument See merge request !1
Diffstat (limited to 'tests')
-rw-r--r--tests/test_connection.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py
new file mode 100644
index 0000000..d4fb134
--- /dev/null
+++ b/tests/test_connection.py
@@ -0,0 +1,18 @@
+import unittest
+
+from unittest.mock import patch, Mock
+
+from prometheus_pgbouncer_exporter import utils
+
+class ConnectionTest(unittest.TestCase):
+
+ @patch('prometheus_pgbouncer_exporter.utils.psycopg2.connect')
+ def test_get_connection_with_host_and_dbname(self, connect):
+ conn = utils.get_connection(host='/tmp/', dbname='template1')
+ connect.assert_called_once_with(host='/tmp/', dbname='template1')
+ connect.return_value.set_session.assert_called_once_with(autocommit=True)
+
+ @patch('prometheus_pgbouncer_exporter.utils.psycopg2.connect')
+ def test_get_connection_with_old_args_plus_password_works(self, connect):
+ conn = utils.get_connection(user='pablo', port=5432, host='localhost', password='mypassword')
+ connect.assert_called_once_with(dbname='pgbouncer', user='pablo', port=5432, host='localhost', password='mypassword')