Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tempstorage
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
tempstorage
Commits
adb57282
Commit
adb57282
authored
May 02, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out the ZODB protocol tests from the tests specific to the module.
Make the local tests use "normal" unittest conventions.
parent
b1781de0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
37 deletions
+89
-37
src/tempstorage/tests/testTemporaryStorage.py
src/tempstorage/tests/testTemporaryStorage.py
+89
-37
No files found.
src/tempstorage/tests/testTemporaryStorage.py
View file @
adb57282
...
...
@@ -17,29 +17,77 @@ from ZODB.tests import StorageTestBase
from
ZODB.tests
import
BasicStorage
from
ZODB.tests
import
Synchronization
from
ZODB.tests
import
ConflictResolution
from
ZODB.tests
import
Corruption
from
ZODB.tests
import
MTStorage
class
ZODBProtocolTests
(
StorageTestBase
.
StorageTestBase
,
# not a revision storage, but passes
#RevisionStorage.RevisionStorage,
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
MTStorage
.
MTStorage
,
):
class
TemporaryStorageTests
(
StorageTestBase
.
StorageTestBase
,
# not a revision storage, but passes
#RevisionStorage.RevisionStorage,
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
MTStorage
.
MTStorage
,
):
def
setUp
(
self
):
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
self
.
open
()
def
open
(
self
,
**
kwargs
):
from
tempstorage.TemporaryStorage
import
TemporaryStorage
self
.
_storage
=
TemporaryStorage
(
'foo'
)
def
setUp
(
self
):
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
self
.
open
()
def
tearDown
(
self
):
StorageTestBase
.
StorageTestBase
.
tearDown
(
self
)
class
TemporaryStorageTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
tempstorage.TemporaryStorage
import
TemporaryStorage
return
TemporaryStorage
def
_makeOne
(
self
,
name
=
'foo'
):
return
self
.
_getTargetClass
()(
name
)
def
_dostore
(
self
,
storage
,
oid
=
None
,
revid
=
None
,
data
=
None
,
already_pickled
=
0
,
user
=
None
,
description
=
None
):
# Borrowed from StorageTestBase, to allow passing storage.
"""Do a complete storage transaction. The defaults are:
- oid=None, ask the storage for a new oid
- revid=None, use a revid of ZERO
- data=None, pickle up some arbitrary data (the integer 7)
Returns the object's new revision id.
"""
import
transaction
from
ZODB.tests.MinPO
import
MinPO
if
oid
is
None
:
oid
=
storage
.
new_oid
()
if
revid
is
None
:
revid
=
StorageTestBase
.
ZERO
if
data
is
None
:
data
=
MinPO
(
7
)
if
type
(
data
)
==
int
:
data
=
MinPO
(
data
)
if
not
already_pickled
:
data
=
StorageTestBase
.
zodb_pickle
(
data
)
# Begin the transaction
t
=
transaction
.
Transaction
()
if
user
is
not
None
:
t
.
user
=
user
if
description
is
not
None
:
t
.
description
=
description
try
:
storage
.
tpc_begin
(
t
)
# Store an object
r1
=
storage
.
store
(
oid
,
revid
,
data
,
''
,
t
)
# Finish the transaction
r2
=
storage
.
tpc_vote
(
t
)
revid
=
StorageTestBase
.
handle_serials
(
oid
,
r1
,
r2
)
storage
.
tpc_finish
(
t
)
except
:
storage
.
tpc_abort
(
t
)
raise
return
revid
def
_do_read_conflict
(
self
,
db
,
mvcc
):
import
transaction
...
...
@@ -75,55 +123,59 @@ class TemporaryStorageTests(StorageTestBase.StorageTestBase,
obj
.
child1
return
obj
def
checkConflictCacheIsCleared
(
self
):
def
test_conflict_cache_clears_over_time
(
self
):
import
time
from
ZODB.tests.MinPO
import
MinPO
self
.
_storage
.
_conflict_cache_gcevery
=
1
# second
self
.
_storage
.
_conflict_cache_maxage
=
1
# second
storage
=
self
.
_makeOne
()
storage
.
_conflict_cache_gcevery
=
1
# second
storage
.
_conflict_cache_maxage
=
1
# second
oid
=
s
elf
.
_s
torage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
5
))
oid
=
storage
.
new_oid
()
self
.
_dostore
(
storage
,
oid
,
data
=
MinPO
(
5
))
time
.
sleep
(
2
)
oid2
=
s
elf
.
_s
torage
.
new_oid
()
self
.
_dostore
(
oid2
,
data
=
MinPO
(
10
))
oid2
=
storage
.
new_oid
()
self
.
_dostore
(
storage
,
oid2
,
data
=
MinPO
(
10
))
oid3
=
s
elf
.
_s
torage
.
new_oid
()
self
.
_dostore
(
oid3
,
data
=
MinPO
(
9
))
oid3
=
storage
.
new_oid
()
self
.
_dostore
(
storage
,
oid3
,
data
=
MinPO
(
9
))
self
.
assertEqual
(
len
(
s
elf
.
_s
torage
.
_conflict_cache
),
2
)
self
.
assertEqual
(
len
(
storage
.
_conflict_cache
),
2
)
time
.
sleep
(
2
)
oid4
=
s
elf
.
_s
torage
.
new_oid
()
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
oid4
=
storage
.
new_oid
()
self
.
_dostore
(
storage
,
oid4
,
data
=
MinPO
(
11
))
self
.
assertEqual
(
len
(
s
elf
.
_s
torage
.
_conflict_cache
),
1
)
self
.
assertEqual
(
len
(
storage
.
_conflict_cache
),
1
)
def
checkWithMVCCDoesntRaise
ReadConflict
(
self
):
def
test_have_MVCC_ergo_no_
ReadConflict
(
self
):
from
ZODB.DB
import
DB
from
ZODB.tests.MinPO
import
MinPO
db
=
DB
(
self
.
_storage
)
storage
=
self
.
_makeOne
()
db
=
DB
(
storage
)
ob
=
self
.
_do_read_conflict
(
db
,
True
)
self
.
assertEquals
(
ob
.
__class__
,
MinPO
)
self
.
assertEquals
(
getattr
(
ob
,
'child1'
,
MinPO
()).
value
,
'child1'
)
self
.
failIf
(
getattr
(
ob
,
'child2'
,
None
))
def
checkLoadEx
(
self
):
def
test_load_ex_matches_load
(
self
):
from
ZODB.tests.MinPO
import
MinPO
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
1
))
loadp
,
loads
=
self
.
_storage
.
load
(
oid
,
'whatever'
)
exp
,
exs
,
exv
=
self
.
_storage
.
loadEx
(
oid
,
'whatever'
)
storage
=
self
.
_makeOne
()
oid
=
storage
.
new_oid
()
self
.
_dostore
(
storage
,
oid
,
data
=
MinPO
(
1
))
loadp
,
loads
=
storage
.
load
(
oid
,
'whatever'
)
exp
,
exs
,
exv
=
storage
.
loadEx
(
oid
,
'whatever'
)
self
.
assertEqual
(
loadp
,
exp
)
self
.
assertEqual
(
loads
,
exs
)
self
.
assertEqual
(
exv
,
''
)
def
test_suite
():
# Note: we follow the ZODB 'check' pattern here so that the base
# class tests are picked up.
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
TemporaryStorageTests
,
'check'
),
unittest
.
makeSuite
(
TemporaryStorageTests
),
# Note: we follow the ZODB 'check' pattern here so that the base
# class tests are picked up.
unittest
.
makeSuite
(
ZODBProtocolTests
,
'check'
),
))
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