diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2017-06-10 23:56:09 +0200 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2017-06-10 23:56:09 +0200 |
commit | b6ee32324517afe3f35e5c85b95b924718fff9af (patch) | |
tree | 7710de52af5bf88117b962604dd8b6f1732996c3 /tests | |
parent | 4884e2374cb1a5fa70c882cb985d2b53cb07e48e (diff) | |
download | prometheus-pgbouncer-exporter-b6ee32324517afe3f35e5c85b95b924718fff9af.tar prometheus-pgbouncer-exporter-b6ee32324517afe3f35e5c85b95b924718fff9af.tar.gz |
Moar tests for get_connection
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_connection.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py index 1c0f4ea..d4fb134 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -5,8 +5,14 @@ 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): + 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') |