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
4a85566c
Commit
4a85566c
authored
Dec 18, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage for Transaction.register.
parent
0ef2f8d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
transaction/_transaction.py
transaction/_transaction.py
+0
-1
transaction/tests/test__transaction.py
transaction/tests/test__transaction.py
+40
-0
No files found.
transaction/_transaction.py
View file @
4a85566c
...
@@ -234,7 +234,6 @@ class Transaction(object):
...
@@ -234,7 +234,6 @@ class Transaction(object):
# be stored when the transaction commits. For other
# be stored when the transaction commits. For other
# objects, the object implements the standard two-phase
# objects, the object implements the standard two-phase
# commit protocol.
# commit protocol.
manager
=
getattr
(
obj
,
"_p_jar"
,
obj
)
manager
=
getattr
(
obj
,
"_p_jar"
,
obj
)
if
manager
is
None
:
if
manager
is
None
:
raise
ValueError
(
"Register with no manager"
)
raise
ValueError
(
"Register with no manager"
)
...
...
transaction/tests/test__transaction.py
View file @
4a85566c
...
@@ -290,6 +290,46 @@ class TransactionTests(unittest.TestCase):
...
@@ -290,6 +290,46 @@ class TransactionTests(unittest.TestCase):
t
.
_invalidate_all_savepoints
()
t
.
_invalidate_all_savepoints
()
self
.
assertEqual
(
list
(
t
.
_savepoint2index
),
[])
self
.
assertEqual
(
list
(
t
.
_savepoint2index
),
[])
def
test_register_wo_jar
(
self
):
class
_Dummy
(
object
):
_p_jar
=
None
t
=
self
.
_makeOne
()
self
.
assertRaises
(
ValueError
,
t
.
register
,
_Dummy
())
def
test_register_w_jar
(
self
):
class
_Manager
(
object
):
pass
mgr
=
_Manager
()
class
_Dummy
(
object
):
_p_jar
=
mgr
t
=
self
.
_makeOne
()
dummy
=
_Dummy
()
t
.
register
(
dummy
)
resources
=
list
(
t
.
_resources
)
self
.
assertEqual
(
len
(
resources
),
1
)
adapter
=
resources
[
0
]
self
.
assertTrue
(
adapter
.
manager
is
mgr
)
self
.
assertTrue
(
dummy
in
adapter
.
objects
)
items
=
list
(
t
.
_adapters
.
items
())
self
.
assertEqual
(
len
(
items
),
1
)
self
.
assertTrue
(
items
[
0
][
0
]
is
mgr
)
self
.
assertTrue
(
items
[
0
][
1
]
is
adapter
)
def
test_register_w_jar_already_adapted
(
self
):
class
_Adapter
(
object
):
def
__init__
(
self
):
self
.
objects
=
[]
class
_Manager
(
object
):
pass
mgr
=
_Manager
()
class
_Dummy
(
object
):
_p_jar
=
mgr
t
=
self
.
_makeOne
()
t
.
_adapters
[
mgr
]
=
adapter
=
_Adapter
()
dummy
=
_Dummy
()
t
.
register
(
dummy
)
self
.
assertTrue
(
dummy
in
adapter
.
objects
)
def
test_note
(
self
):
def
test_note
(
self
):
t
=
self
.
_makeOne
()
t
=
self
.
_makeOne
()
try
:
try
:
...
...
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