Exemplo n.º 1
0
 def test_connection_factory(self):
     """Testing that connection_factory parameter is properly propagated"""
     conn = yield momoko.connect(self.dsn,
                                 ioloop=self.io_loop,
                                 connection_factory=RealDictConnection)
     cursor = yield conn.execute("SELECT 1 AS a")
     self.assertEqual(cursor.fetchone(), {"a": 1})
Exemplo n.º 2
0
Arquivo: tests.py Projeto: FSX/momoko
    def test_setsession(self):
        """Testing that setssion parameter is honoured"""
        setsession = deque([None, "SELECT 1", "SELECT 2"])
        time_zones = ["UTC", "Israel", "Australia/Melbourne"]

        for i in range(len(time_zones)):
            setsession[i] = "SET TIME ZONE '%s'" % time_zones[i]
            conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, setsession=setsession)
            cursor = yield conn.execute("SELECT current_setting('TIMEZONE');")
            self.assertEqual(cursor.fetchall(), [(time_zones[i],)])
            conn.close()
            setsession.rotate(1)
Exemplo n.º 3
0
    def test_setsession(self):
        """Testing that setssion parameter is honoured"""
        setsession = deque([None, "SELECT 1", "SELECT 2"])
        time_zones = ["UTC", "Israel", "Australia/Melbourne"]

        for i in range(len(time_zones)):
            setsession[i] = "SET TIME ZONE '%s'" % time_zones[i]
            conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, setsession=setsession)
            cursor = yield conn.execute("SELECT current_setting('TIMEZONE');")
            self.assertEqual(cursor.fetchall(), [(time_zones[i],)])
            conn.close()
            setsession.rotate(1)
Exemplo n.º 4
0
 def test_ping_with_named_cursor(self):
     """Test whether Connection.ping works fine with named cursors. Issue #74"""
     conn = yield momoko.connect(self.dsn,
                                 ioloop=self.io_loop,
                                 cursor_factory=RealDictCursor)
     yield conn.ping()
Exemplo n.º 5
0
 def test_bad_connect_local(self):
     """Test that Connection raises connection errors when using local socket"""
     try:
         yield momoko.connect(local_bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
Exemplo n.º 6
0
 def test_connect(self):
     """Test that Connection can connect to the database"""
     conn = yield momoko.connect(good_dsn, ioloop=self.io_loop)
     self.assertIsInstance(conn, momoko.Connection)
Exemplo n.º 7
0
 def set_up_10(self):
     self.conn = yield momoko.connect(self.dsn, ioloop=self.io_loop)
     for g in chain(self.clean_db(), self.prepare_db()):
         yield g
Exemplo n.º 8
0
Arquivo: tests.py Projeto: FSX/momoko
 def test_cursor_factory_with_json(self):
     """Testing that register_json works with RealDictCursor"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, cursor_factory=RealDictCursor)
     yield conn.register_json()
     cursor = yield conn.execute("SELECT 1 AS a")
     self.assertEqual(cursor.fetchone(), {"a": 1})
Exemplo n.º 9
0
Arquivo: tests.py Projeto: FSX/momoko
 def test_ping_with_named_cursor(self):
     """Test whether Connection.ping works fine with named cursors. Issue #74"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, cursor_factory=RealDictCursor)
     yield conn.ping()
Exemplo n.º 10
0
Arquivo: tests.py Projeto: FSX/momoko
 def test_connection_factory(self):
     """Testing that connection_factory parameter is properly propagated"""
     conn = yield momoko.connect(self.dsn, ioloop=self.io_loop, connection_factory=RealDictConnection)
     cursor = yield conn.execute("SELECT 1 AS a")
     self.assertEqual(cursor.fetchone(), {"a": 1})
Exemplo n.º 11
0
Arquivo: tests.py Projeto: FSX/momoko
 def test_bad_connect_local(self):
     """Test that Connection raises connection errors when using local socket"""
     try:
         yield momoko.connect(local_bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
Exemplo n.º 12
0
Arquivo: tests.py Projeto: FSX/momoko
 def test_connect(self):
     """Test that Connection can connect to the database"""
     conn = yield momoko.connect(good_dsn, ioloop=self.io_loop)
     self.assertIsInstance(conn, momoko.Connection)
Exemplo n.º 13
0
Arquivo: tests.py Projeto: FSX/momoko
 def set_up_10(self):
     self.conn = yield momoko.connect(self.dsn, ioloop=self.io_loop)
     for g in chain(self.clean_db(), self.prepare_db()):
         yield g
Exemplo n.º 14
0
 def test_bad_connect(self):
     """Test that Connection raises connection errors"""
     try:
         conn = yield momoko.connect(bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
Exemplo n.º 15
0
 def test_bad_connect(self):
     """Test that Connection raises connection errors"""
     try:
         conn = yield momoko.connect(bad_dsn, ioloop=self.io_loop)
     except Exception as error:
         self.assertIsInstance(error, psycopg2.OperationalError)
Exemplo n.º 16
0
 def set_up_10(self):
     self.conn = yield momoko.connect(self.dsn, ioloop=self.io_loop)