aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPablo Carranza <pcarranza@gmail.com>2017-06-10 23:45:51 +0200
committerPablo Carranza <pcarranza@gmail.com>2017-06-10 23:45:51 +0200
commit730f895edee9a6201741b4e511c2572fcb56649d (patch)
tree9f4fb75abc63385de98960595529a810165a1f4a /tests
parent11b7cefa15062ef21769e373d28a156b861db9cc (diff)
downloadprometheus-pgbouncer-exporter-730f895edee9a6201741b4e511c2572fcb56649d.tar
prometheus-pgbouncer-exporter-730f895edee9a6201741b4e511c2572fcb56649d.tar.gz
Add one test, at least
Diffstat (limited to 'tests')
-rw-r--r--tests/test_connection.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py
new file mode 100644
index 0000000..1c0f4ea
--- /dev/null
+++ b/tests/test_connection.py
@@ -0,0 +1,12 @@
+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_password_works(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)