Beispiel #1
0
 def test_unix_domain_socket(self, connect):
     with _patch_db("postgresql+psycopg2://usrn:pwd@/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(host=None,
                                         port=None,
                                         user="******",
                                         password="******",
                                         database="dbname")
Beispiel #2
0
 def test_missing_password(self, connect):
     with _patch_db("postgresql+psycopg2://u@h:1/db"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(host="h",
                                         port=1,
                                         user="******",
                                         password=None,
                                         database="db")
Beispiel #3
0
 def test_network(self, connect):
     # Simple TCP connection.
     with _patch_db("postgresql+psycopg2://usrn:pwd@hooost:5433/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(host="hooost",
                                         port=5433,
                                         user="******",
                                         password="******",
                                         database="dbname")
Beispiel #4
0
 def test_network_missing_port(self, connect):
     # If port is missing, the default 5432 is used.
     with _patch_db("postgresql+psycopg2://usrn:pwd@hooost/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(host="hooost",
                                         port=5432,
                                         user="******",
                                         password="******",
                                         database="dbname")
Beispiel #5
0
 def test_missing_password(self, connect):
     with _patch_db("postgresql+psycopg2://u@h:1/db"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(
             host="h",
             port=1,
             user="******",
             password=None,
             database="db")
Beispiel #6
0
 def test_unix_domain_socket(self, connect):
     with _patch_db("postgresql+psycopg2://usrn:pwd@/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(
             host=None,
             port=None,
             user="******",
             password="******",
             database="dbname")
Beispiel #7
0
 def test_network_missing_port(self, connect):
     # If port is missing, the default 5432 is used.
     with _patch_db("postgresql+psycopg2://usrn:pwd@hooost/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(
             host="hooost",
             port=5432,
             user="******",
             password="******",
             database="dbname")
Beispiel #8
0
 def test_network(self, connect):
     # Simple TCP connection.
     with _patch_db("postgresql+psycopg2://usrn:pwd@hooost:5433/dbname"):
         r = custom_psycopg2_connection()
         self.assertIs(r, connect.return_value)
         connect.assert_called_once_with(
             host="hooost",
             port=5433,
             user="******",
             password="******",
             database="dbname")
Beispiel #9
0
 def test_not_psycopg2(self, connect):
     with _patch_db("sqlite://file"):
         with self.assertRaises(AssertionError):
             custom_psycopg2_connection()
Beispiel #10
0
 def test_not_psycopg2(self, connect):
     with _patch_db("sqlite://file"):
         with self.assertRaises(AssertionError):
             custom_psycopg2_connection()