Exemplo n.º 1
0
 def test_cancel_transaction(self):
     db = DataBase(store)
     self.assertFalse(db.in_transaction())
     r = db.cancel_transaction()
     self.assertFalse(r)
     with db.transaction():
         self.assertTrue(db.in_transaction())
         id = db.execute(
             'insert into foo(name, age, age_str, `key`) values(%s, %s, %s, %s)',
             ('foo', 1, '1', '1'))
         r = db.cancel_transaction()
         self.assertTrue(r)
     rv = db.execute('select * from foo where id = %s', id)
     self.assertEqual(rv, ())
Exemplo n.º 2
0
 def test_cancel_transaction(self):
     db = DataBase(store)
     self.assertFalse(db.in_transaction())
     r = db.cancel_transaction()
     self.assertFalse(r)
     with start_transaction(db):
         self.assertTrue(db.in_transaction())
         if is_pg:
             id = db.execute(
                 'insert into foo(name, age, age_str, "key") values(%s, %s, %s, %s)',
                 ('foo', 1, '1', '1'))
         else:
             id = db.execute(
                 'insert into foo(name, age, age_str, `key`) values(%s, %s, %s, %s)',
                 ('foo', 1, '1', '1'))
         r = db.cancel_transaction()
         self.assertTrue(r)
     with start_transaction(db):
         rv = db.execute('select * from foo where id = %s', (id, ))
     # FIXME(PG)
     if is_pg:
         self.assertEqual(rv, [])
     else:
         self.assertEqual(rv, ())