From: Mike Bayer Date: Fri, 5 May 2006 17:52:00 +0000 (+0000) Subject: got removed somehow X-Git-Tag: rel_0_2_0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=116295d097ad957cd88bafb00be4931673fa3a02;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git got removed somehow --- diff --git a/test/engine.py b/test/engine.py new file mode 100644 index 0000000000..193201fa19 --- /dev/null +++ b/test/engine.py @@ -0,0 +1,64 @@ +from sqlalchemy import * + +from testbase import PersistTest +import testbase +import unittest, re +import tables + +class TransactionTest(PersistTest): + def setUpAll(self): + tables.create() + def tearDownAll(self): + tables.drop() + def tearDown(self): + tables.delete() + + def testbasic(self): + testbase.db.begin() + tables.users.insert().execute(user_name='jack') + tables.users.insert().execute(user_name='fred') + testbase.db.commit() + l = tables.users.select().execute().fetchall() + print l + self.assert_(len(l) == 2) + + def testrollback(self): + testbase.db.begin() + tables.users.insert().execute(user_name='jack') + tables.users.insert().execute(user_name='fred') + testbase.db.rollback() + l = tables.users.select().execute().fetchall() + print l + self.assert_(len(l) == 0) + + @testbase.unsupported('sqlite') + def testnested(self): + """tests nested sessions. SQLite should raise an error.""" + testbase.db.begin() + tables.users.insert().execute(user_name='jack') + tables.users.insert().execute(user_name='fred') + testbase.db.push_session() + tables.users.insert().execute(user_name='ed') + tables.users.insert().execute(user_name='wendy') + testbase.db.pop_session() + testbase.db.rollback() + l = tables.users.select().execute().fetchall() + print l + self.assert_(len(l) == 2) + + def testtwo(self): + testbase.db.begin() + tables.users.insert().execute(user_name='jack') + tables.users.insert().execute(user_name='fred') + testbase.db.commit() + testbase.db.begin() + tables.users.insert().execute(user_name='ed') + tables.users.insert().execute(user_name='wendy') + testbase.db.commit() + testbase.db.rollback() + l = tables.users.select().execute().fetchall() + print l + self.assert_(len(l) == 4) + +if __name__ == "__main__": + testbase.main()