Example #1
0
 def test_rollback(self):
     transaction.begin()
     zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
     self._txn_registered = True
     zc.rollback()
     self.assertEqual(zc._txn_registered, False,
                      "did not forget the transaction")
 def test_rollback(self):
     transaction.begin()
     zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
     self._txn_registered = True
     zc.rollback()
     self.assertEqual(zc._txn_registered, False,
                      "did not forget the transaction")
Example #3
0
    def test_connection_txn_registration(self):
        transaction.begin()

        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()
        cursor.execute('select * from blah')

        self.assertEqual(zc._txn_registered, True)
        self.assertEqual(len(transaction.get()._resources), 1)
    def test_connection_txn_registration(self):
        transaction.begin()

        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()
        cursor.execute('select * from blah')

        self.assertEqual(zc._txn_registered, True)
        self.assertEqual(len(transaction.get()._resources), 1)
Example #5
0
 def setUp(self):
     self.conn1 = ConnectionStub()
     self.conn2 = ConnectionStub()
     zc1 = ZopeConnection(self.conn1, TypeInfoStub())
     self.datamgr1 = ZopeDBTransactionManager(zc1)
     zc2 = ZopeConnection(self.conn2, TypeInfoStub())
     self.datamgr1 = ZopeDBTransactionManager(zc2)
     zc1.registerForTxn()
     zc2.registerForTxn()
     self.txn_factory = transaction.get
    def test_cursor_executemany(self):
        self.cursor.executemany("SELECT", [("A", ), ("B", )])
        self.assertEqual("execute", self.cursor.cursor.method)
        self.assertEqual("SELECT", self.cursor.cursor.query)
        self.assertEqual([("A", ), ("B", )], self.cursor.cursor.args)

        zc = ZopeConnection(MyConnectionStub2(), self.typeInfo)
        self.cursor = ZopeCursor(zc.conn.cursor(), zc)
        self.cursor.executemany("SELECT", [("A", ), ("B", )])
        self.assertEqual("executemany", self.cursor.cursor.method)
        self.assertEqual("SELECT", self.cursor.cursor.query)
        self.assertEqual([("A", ), ("B", )], self.cursor.cursor.args)
 def setUp(self):
     self.conn1 = ConnectionStub()
     self.conn2 = ConnectionStub()
     zc1 = ZopeConnection(self.conn1, TypeInfoStub())
     self.datamgr1 = ZopeDBTransactionManager(zc1)
     zc2 = ZopeConnection(self.conn2, TypeInfoStub())
     self.datamgr1 = ZopeDBTransactionManager(zc2)
     zc1.registerForTxn()
     zc2.registerForTxn()
     self.txn_factory = transaction.get
Example #8
0
 def commit(self):
     try:
         ZopeConnection.commit(self)
     except psycopg2.Error as error:
         _handle_psycopg_exception(error)
 def setUp(self):
     self.typeInfo = MyTypeInfoStub()
     zc = ZopeConnection(MyConnectionStub(), self.typeInfo)
     self.cursor = ZopeCursor(zc.conn.cursor(), zc)
Example #10
0
    def test_getattr(self):
        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()

        self.assertEqual(zc.answer(), 42)
Example #11
0
    def test_cursor(self):
        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()

        self.failUnless(IZopeCursor.providedBy(cursor),
                        "cursor is not what we expected")
    def test_getattr(self):
        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()

        self.assertEqual(zc.answer(), 42)
    def test_cursor(self):
        zc = ZopeConnection(ConnectionStub(), TypeInfoStub())
        cursor = zc.cursor()

        self.failUnless(IZopeCursor.providedBy(cursor),
                        "cursor is not what we expected")
Example #14
0
 def commit(self):
     try:
         ZopeConnection.commit(self)
     except psycopg2.Error, error:
         _handle_psycopg_exception(error)
Example #15
0
 def setUp(self):
     self.conn = ConnectionStub()
     zc = ZopeConnection(self.conn, TypeInfoStub())
     self.datamgr = ZopeDBTransactionManager(zc)
     zc.registerForTxn()
     self.txn_factory = transaction.get
 def setUp(self):
     self.conn = ConnectionStub()
     zc = ZopeConnection(self.conn, TypeInfoStub())
     self.datamgr = ZopeDBTransactionManager(zc)
     zc.registerForTxn()
     self.txn_factory = transaction.get