~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/database/ftests/script_isolation.py

  • Committer: Stuart Bishop
  • Date: 2011-09-28 12:49:24 UTC
  • mfrom: (9893.10.1 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20110928124924-m5a22fymqghw6c5i
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Script run from test_isolation.py to confirm transaction isolation
18
18
 
19
19
import transaction
20
20
 
21
 
from canonical.database.sqlbase import (
22
 
    cursor,
23
 
    ISOLATION_LEVEL_SERIALIZABLE,
24
 
    ZopelessTransactionManager,
25
 
    )
 
21
from canonical.config import dbconfig
 
22
from canonical.database.sqlbase import cursor
26
23
from canonical.launchpad.scripts import execute_zcml_for_scripts
 
24
from canonical.testing.layers import disconnect_stores
27
25
 
28
26
execute_zcml_for_scripts()
29
27
 
 
28
 
30
29
def check():
31
30
    cur = cursor()
32
31
    cur.execute("UPDATE Person SET homepage_content='foo' WHERE name='mark'")
41
40
    cur.execute("SHOW transaction_isolation")
42
41
    print cur.fetchone()[0]
43
42
 
44
 
# First confirm the default isolation level
45
 
ZopelessTransactionManager.initZopeless(dbuser='launchpad_main')
 
43
dbconfig.override(dbuser='launchpad_main', isolation_level='read_committed')
 
44
disconnect_stores()
46
45
check()
47
 
ZopelessTransactionManager.uninstall()
48
46
 
49
 
ZopelessTransactionManager.initZopeless(
50
 
    dbuser='launchpad_main',
51
 
    isolation=ISOLATION_LEVEL_SERIALIZABLE)
 
47
dbconfig.override(isolation_level='serializable')
 
48
disconnect_stores()
52
49
check()
53
 
ZopelessTransactionManager.uninstall()