Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
transaction
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
transaction
Commits
fb2f9ce1
Commit
fb2f9ce1
authored
Dec 17, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean out module-scope imports: .tests.test_savepoint
parent
69923979
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
69 deletions
+44
-69
transaction/tests/test_savepoint.py
transaction/tests/test_savepoint.py
+44
-69
No files found.
transaction/tests/test_savepoint.py
View file @
fb2f9ce1
...
...
@@ -11,81 +11,56 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests of savepoint feature
"""
import
unittest
import
doctest
def
testRollbackRollsbackDataManagersThatJoinedLater
():
"""
A savepoint needs to not just rollback it's savepoints, but needs to
rollback savepoints for data managers that joined savepoints after the
savepoint:
>>> import transaction
>>> from transaction.tests import savepointsample
>>> dm = savepointsample.SampleSavepointDataManager()
>>> dm['name'] = 'bob'
>>> sp1 = transaction.savepoint()
>>> dm['job'] = 'geek'
>>> sp2 = transaction.savepoint()
>>> dm['salary'] = 'fun'
>>> dm2 = savepointsample.SampleSavepointDataManager()
>>> dm2['name'] = 'sally'
>>> 'name' in dm
True
>>> 'job' in dm
True
>>> 'salary' in dm
True
>>> 'name' in dm2
True
>>> sp1.rollback()
>>> 'name' in dm
True
>>> 'job' in dm
False
>>> 'salary' in dm
False
>>> 'name' in dm2
False
"""
def
test_commit_after_rollback_for_dm_that_joins_after_savepoint
():
"""
There was a problem handling data managers that joined after a
savepoint. If the savepoint was rolled back and then changes made,
the dm would end up being joined twice, leading to extra tpc calls and pain.
>>> import transaction
>>> sp = transaction.savepoint()
>>> from transaction.tests import savepointsample
>>> dm = savepointsample.SampleSavepointDataManager()
>>> dm['name'] = 'bob'
>>> sp.rollback()
>>> dm['name'] = 'Bob'
>>> transaction.commit()
>>> dm['name']
'Bob'
"""
class
SavepointTests
(
unittest
.
TestCase
):
def
testRollbackRollsbackDataManagersThatJoinedLater
(
self
):
# A savepoint needs to not just rollback it's savepoints, but needs
# to # rollback savepoints for data managers that joined savepoints
# after the savepoint:
import
transaction
from
transaction.tests
import
savepointsample
dm
=
savepointsample
.
SampleSavepointDataManager
()
dm
[
'name'
]
=
'bob'
sp1
=
transaction
.
savepoint
()
dm
[
'job'
]
=
'geek'
sp2
=
transaction
.
savepoint
()
dm
[
'salary'
]
=
'fun'
dm2
=
savepointsample
.
SampleSavepointDataManager
()
dm2
[
'name'
]
=
'sally'
self
.
assertTrue
(
'name'
in
dm
)
self
.
assertTrue
(
'job'
in
dm
)
self
.
assertTrue
(
'salary'
in
dm
)
self
.
assertTrue
(
'name'
in
dm2
)
sp1
.
rollback
()
self
.
assertTrue
(
'name'
in
dm
)
self
.
assertFalse
(
'job'
in
dm
)
self
.
assertFalse
(
'salary'
in
dm
)
self
.
assertFalse
(
'name'
in
dm2
)
def
test_commit_after_rollback_for_dm_that_joins_after_savepoint
(
self
):
# There was a problem handling data managers that joined after a
# savepoint. If the savepoint was rolled back and then changes
# made, the dm would end up being joined twice, leading to extra
# tpc calls and pain.
import
transaction
from
transaction.tests
import
savepointsample
sp
=
transaction
.
savepoint
()
dm
=
savepointsample
.
SampleSavepointDataManager
()
dm
[
'name'
]
=
'bob'
sp
.
rollback
()
dm
[
'name'
]
=
'Bob'
transaction
.
commit
()
self
.
assertEqual
(
dm
[
'name'
],
'Bob'
)
def
test_suite
():
return
unittest
.
TestSuite
((
doctest
.
DocTestSuite
(
),
unittest
.
makeSuite
(
SavepointTests
),
))
# additional_tests is for setuptools "setup.py test" support
additional_tests
=
test_suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment