[Checkins] SVN: zope.sqlalchemy/trunk/ Add test that tries to reproduce behaviour in case of a conflict error; add postgres and sqlalchemy 0.4 test buildout; fix tests that are 0.5 only to be skipped on 0.4
Laurence Rowe
l at lrowe.co.uk
Mon Jul 6 04:40:32 EDT 2009
Log message for revision 101608:
Add test that tries to reproduce behaviour in case of a conflict error; add postgres and sqlalchemy 0.4 test buildout; fix tests that are 0.5 only to be skipped on 0.4
Changed:
U zope.sqlalchemy/trunk/buildout.cfg
A zope.sqlalchemy/trunk/postgres-sa04.cfg
U zope.sqlalchemy/trunk/src/zope/sqlalchemy/tests.py
-=-
Modified: zope.sqlalchemy/trunk/buildout.cfg
===================================================================
--- zope.sqlalchemy/trunk/buildout.cfg 2009-07-06 08:18:53 UTC (rev 101607)
+++ zope.sqlalchemy/trunk/buildout.cfg 2009-07-06 08:40:32 UTC (rev 101608)
@@ -9,5 +9,5 @@
[scripts]
recipe = zc.recipe.egg
-eggs = zope.sqlalchemy
+eggs = ${test:eggs}
interpreter = py
Added: zope.sqlalchemy/trunk/postgres-sa04.cfg
===================================================================
--- zope.sqlalchemy/trunk/postgres-sa04.cfg (rev 0)
+++ zope.sqlalchemy/trunk/postgres-sa04.cfg 2009-07-06 08:40:32 UTC (rev 101608)
@@ -0,0 +1,26 @@
+# PATH=/opt/local/lib/postgresql83/bin:$PATH bin/buildout -vvvc postgres.cfg
+# /opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb -d 1
+[buildout]
+extends = buildout.cfg
+find-links = http://initd.org/pub/software/psycopg/
+versions = versions
+
+[versions]
+SQLAlchemy = 0.4.8
+z3c.sqlalchemy = 1.1.15
+zope.component = 3.4.0
+
+[test]
+eggs +=
+ psycopg2
+ z3c.sqlalchemy
+ zope.component
+ zope.exceptions
+ zope.schema
+environment = testenv
+
+[scripts]
+eggs = ${test:eggs}
+
+[testenv]
+TEST_DSN = postgres:///zope_sqlalchemy_tests
Modified: zope.sqlalchemy/trunk/src/zope/sqlalchemy/tests.py
===================================================================
--- zope.sqlalchemy/trunk/src/zope/sqlalchemy/tests.py 2009-07-06 08:18:53 UTC (rev 101607)
+++ zope.sqlalchemy/trunk/src/zope/sqlalchemy/tests.py 2009-07-06 08:40:32 UTC (rev 101608)
@@ -175,6 +175,27 @@
for m in self.mappers:
m.dispose()
+ def testAbortBeforeCommit(self):
+ # Simulate what happens in a conflict error
+ dummy = DummyDataManager(key='dummy.first')
+ session = Session()
+ conn = session.connection()
+ mark_changed(session)
+ try:
+ # Thus we could fail in commit
+ transaction.commit()
+ except:
+ # But abort must succed (and actually rollback the base connection)
+ transaction.abort()
+ pass
+ # Or the next transaction the next transaction will not be able to start!
+ transaction.begin()
+ session = Session()
+ conn = session.connection()
+ conn.execute("SELECT 1")
+ mark_changed(session)
+ transaction.commit()
+
def testAbortAfterCommit(self):
# This is a regression test which used to wedge the transaction
# machinery when using PostgreSQL (and perhaps other) connections.
@@ -418,6 +439,8 @@
raise thread_error # reraise in current thread
def testBulkDelete(self):
+ if SA_0_4:
+ return
session = Session()
session.add(User(id=1, firstname='udo', lastname='juergens'))
session.add(User(id=2, firstname='heino', lastname='n/a'))
@@ -429,6 +452,8 @@
self.assertEqual(len(results.fetchall()), 0)
def testBulkUpdate(self):
+ if SA_0_4:
+ return
session = Session()
session.add(User(id=1, firstname='udo', lastname='juergens'))
session.add(User(id=2, firstname='heino', lastname='n/a'))
More information about the Checkins
mailing list