Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
f351e577
Commit
f351e577
authored
Nov 02, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests to account for ZEO's load() & tpc_vote() return values
parent
5bedc346
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
10 deletions
+49
-10
src/ZODB/tests/BasicStorage.py
src/ZODB/tests/BasicStorage.py
+8
-7
src/ZODB/tests/PackableStorage.py
src/ZODB/tests/PackableStorage.py
+4
-0
src/ZODB/tests/StorageTestBase.py
src/ZODB/tests/StorageTestBase.py
+37
-3
No files found.
src/ZODB/tests/BasicStorage.py
View file @
f351e577
...
@@ -73,10 +73,11 @@ class BasicStorage:
...
@@ -73,10 +73,11 @@ class BasicStorage:
self
.
_storage
.
tpc_begin
(
txn
)
self
.
_storage
.
tpc_begin
(
txn
)
# Use None for serial. Don't use _dostore() here because that coerces
# Use None for serial. Don't use _dostore() here because that coerces
# serial=None to serial=ZERO.
# serial=None to serial=ZERO.
newrevid
=
self
.
_storage
.
store
(
oid
,
None
,
zodb_pickle
(
MinPO
(
11
)),
r1
=
self
.
_storage
.
store
(
oid
,
None
,
zodb_pickle
(
MinPO
(
11
)),
''
,
txn
)
''
,
txn
)
self
.
_storage
.
tpc_vote
(
txn
)
r2
=
self
.
_storage
.
tpc_vote
(
txn
)
self
.
_storage
.
tpc_finish
(
txn
)
self
.
_storage
.
tpc_finish
(
txn
)
newrevid
=
self
.
_handle_serials
(
oid
,
r1
,
r2
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
data
,
revid
=
self
.
_storage
.
load
(
oid
,
''
)
value
=
zodb_unpickle
(
data
)
value
=
zodb_unpickle
(
data
)
eq
(
value
,
MinPO
(
11
))
eq
(
value
,
MinPO
(
11
))
...
@@ -118,22 +119,22 @@ class BasicStorage:
...
@@ -118,22 +119,22 @@ class BasicStorage:
def
checkWriteAfterAbort
(
self
):
def
checkWriteAfterAbort
(
self
):
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
revid
=
self
.
_storage
.
store
(
oid
,
ZERO
,
zodb_pickle
(
MinPO
(
5
)),
self
.
_storage
.
store
(
oid
,
ZERO
,
zodb_pickle
(
MinPO
(
5
)),
''
,
self
.
_transaction
)
''
,
self
.
_transaction
)
# Now abort this transaction
# Now abort this transaction
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
# Now start all over again
# Now start all over again
self
.
_transaction
=
Transaction
()
self
.
_transaction
=
Transaction
()
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
revid
=
self
.
_dostore
(
oid
=
oid
,
data
=
MinPO
(
6
))
self
.
_dostore
(
oid
=
oid
,
data
=
MinPO
(
6
))
def
checkAbortAfterVote
(
self
):
def
checkAbortAfterVote
(
self
):
oid1
=
self
.
_storage
.
new_oid
()
oid1
=
self
.
_storage
.
new_oid
()
revid1
=
self
.
_dostore
(
oid
=
oid1
,
data
=
MinPO
(
-
2
))
revid1
=
self
.
_dostore
(
oid
=
oid1
,
data
=
MinPO
(
-
2
))
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
revid
=
self
.
_storage
.
store
(
oid
,
ZERO
,
zodb_pickle
(
MinPO
(
5
)),
self
.
_storage
.
store
(
oid
,
ZERO
,
zodb_pickle
(
MinPO
(
5
)),
''
,
self
.
_transaction
)
''
,
self
.
_transaction
)
# Now abort this transaction
# Now abort this transaction
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
self
.
_storage
.
tpc_abort
(
self
.
_transaction
)
...
...
src/ZODB/tests/PackableStorage.py
View file @
f351e577
...
@@ -126,6 +126,10 @@ class PackableStorage(PackableStorageBase):
...
@@ -126,6 +126,10 @@ class PackableStorage(PackableStorageBase):
self
.
_initroot
()
self
.
_initroot
()
self
.
_storage
.
pack
(
time
.
time
()
+
10000
,
referencesf
)
self
.
_storage
.
pack
(
time
.
time
()
+
10000
,
referencesf
)
def
checkPackYesterday
(
self
):
self
.
_initroot
()
self
.
_storage
.
pack
(
time
.
time
()
-
10000
,
referencesf
)
def
checkPackAllRevisions
(
self
):
def
checkPackAllRevisions
(
self
):
self
.
_initroot
()
self
.
_initroot
()
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
src/ZODB/tests/StorageTestBase.py
View file @
f351e577
...
@@ -88,6 +88,40 @@ class StorageTestBase(unittest.TestCase):
...
@@ -88,6 +88,40 @@ class StorageTestBase(unittest.TestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
_close
()
self
.
_close
()
def
_handle_all_serials
(
self
,
oid
,
*
args
):
"""Return dict of oid to serialno from store() and tpc_vote().
Raises an exception if one of the calls raised an exception.
The storage interface got complicated when ZEO was introduced.
Any individual store() call can return None or a sequence of
2-tuples where the 2-tuple is either oid, serialno or an
exception to be raised by the client.
The original interface just returned the serialno for the
object.
"""
d
=
{}
for
arg
in
args
:
if
isinstance
(
arg
,
types
.
StringType
):
d
[
oid
]
=
arg
elif
arg
is
None
:
pass
else
:
for
oid
,
serial
in
arg
:
if
not
isinstance
(
serial
,
types
.
StringType
):
raise
arg
d
[
oid
]
=
serial
return
d
def
_handle_serials
(
self
,
oid
,
*
args
):
"""Return the serialno for oid based on multiple return values.
A helper for function _handle_all_serials().
"""
args
=
(
oid
,)
+
args
return
apply
(
self
.
_handle_all_serials
,
args
)[
oid
]
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
def
_dostore
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
,
already_pickled
=
0
):
already_pickled
=
0
):
"""Do a complete storage transaction. The defaults are:
"""Do a complete storage transaction. The defaults are:
...
@@ -114,12 +148,12 @@ class StorageTestBase(unittest.TestCase):
...
@@ -114,12 +148,12 @@ class StorageTestBase(unittest.TestCase):
# Begin the transaction
# Begin the transaction
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
self
.
_storage
.
tpc_begin
(
self
.
_transaction
)
# Store an object
# Store an object
newrevid
=
self
.
_storage
.
store
(
oid
,
revid
,
data
,
version
,
r1
=
self
.
_storage
.
store
(
oid
,
revid
,
data
,
version
,
self
.
_transaction
)
self
.
_transaction
)
# Finish the transaction
# Finish the transaction
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
r2
=
self
.
_storage
.
tpc_vote
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
self
.
_storage
.
tpc_finish
(
self
.
_transaction
)
return
newrevid
return
self
.
_handle_serials
(
oid
,
r1
,
r2
)
def
_dostoreNP
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
):
def
_dostoreNP
(
self
,
oid
=
None
,
revid
=
None
,
data
=
None
,
version
=
None
):
return
self
.
_dostore
(
oid
,
revid
,
data
,
version
,
already_pickled
=
1
)
return
self
.
_dostore
(
oid
,
revid
,
data
,
version
,
already_pickled
=
1
)
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