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
54b8b153
Commit
54b8b153
authored
May 02, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean out module-scope imports, old test driver cruft.
parent
dc56bdab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
71 deletions
+73
-71
src/tempstorage/tests/testTemporaryStorage.py
src/tempstorage/tests/testTemporaryStorage.py
+73
-71
No files found.
src/tempstorage/tests/testTemporaryStorage.py
View file @
54b8b153
import
ZODB
import
unittest
from
ZODB.tests.MinPO
import
MinPO
from
tempstorage
import
TemporaryStorage
from
ZODB.tests
import
StorageTestBase
import
sys
,
os
,
unittest
,
time
from
ZODB.tests
import
BasicStorage
from
ZODB.tests
import
Synchronization
from
ZODB.tests
import
StorageTestBase
,
BasicStorage
,
\
from
ZODB.tests
import
ConflictResolution
Synchronization
,
ConflictResolution
,
\
from
ZODB.tests
import
Corruption
Corruption
,
RevisionStorage
,
MTStorage
from
ZODB.tests
import
MTStorage
from
persistent
import
Persistent
import
transaction
class
TemporaryStorageTests
(
StorageTestBase
.
StorageTestBase
,
from
ZODB.DB
import
DB
# not a revision storage, but passes
from
ZODB.POSException
import
ReadConflictError
#RevisionStorage.RevisionStorage,
class
TemporaryStorageTests
(
StorageTestBase
.
StorageTestBase
,
## RevisionStorage.RevisionStorage, # not a revision storage, but passes
BasicStorage
.
BasicStorage
,
BasicStorage
.
BasicStorage
,
Synchronization
.
SynchronizedStorage
,
Synchronization
.
SynchronizedStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
ConflictResolution
.
ConflictResolvingStorage
,
MTStorage
.
MTStorage
,
MTStorage
.
MTStorage
,
):
):
_old_conflict_cache
=
None
def
open
(
self
,
**
kwargs
):
def
open
(
self
,
**
kwargs
):
self
.
_storage
=
TemporaryStorage
.
TemporaryStorage
(
'foo'
)
from
tempstorage.TemporaryStorage
import
TemporaryStorage
self
.
_storage
=
TemporaryStorage
(
'foo'
)
def
setUp
(
self
):
def
setUp
(
self
):
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
StorageTestBase
.
StorageTestBase
.
setUp
(
self
)
...
@@ -30,31 +29,21 @@ class TemporaryStorageTests(
...
@@ -30,31 +29,21 @@ class TemporaryStorageTests(
def
tearDown
(
self
):
def
tearDown
(
self
):
StorageTestBase
.
StorageTestBase
.
tearDown
(
self
)
StorageTestBase
.
StorageTestBase
.
tearDown
(
self
)
if
self
.
_old_conflict_cache
is
not
None
:
def
checkConflictCacheIsCleared
(
self
):
from
tempstorage
import
TemporaryStorage
as
TS
old_gcevery
=
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
(
TS
.
CONFLICT_CACHE_GCEVERY
,
old_maxage
=
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
TS
.
CONFLICT_CACHE_MAXAGE
)
=
self
.
_old_conflict_cache
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
5
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
5
def
_set_conflict_cache
(
self
,
gcevery
,
maxage
):
try
:
from
tempstorage
import
TemporaryStorage
as
TS
oid
=
self
.
_storage
.
new_oid
()
self
.
_old_conflict_cache
=
(
TS
.
CONFLICT_CACHE_GCEVERY
,
self
.
_dostore
(
oid
,
data
=
MinPO
(
5
))
TS
.
CONFLICT_CACHE_MAXAGE
)
time
.
sleep
(
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
+
1
)
TS
.
CONFLICT_CACHE_GCEVERY
=
gcevery
oid2
=
self
.
_storage
.
new_oid
()
TS
.
CONFLICT_CACHE_MAXAGE
=
maxage
self
.
_dostore
(
oid2
,
data
=
MinPO
(
10
))
oid3
=
self
.
_storage
.
new_oid
()
def
_do_read_conflict
(
self
,
db
,
mvcc
):
self
.
_dostore
(
oid3
,
data
=
MinPO
(
9
))
import
transaction
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
2
from
ZODB.tests.MinPO
import
MinPO
time
.
sleep
(
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
+
1
)
oid4
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
assert
len
(
self
.
_storage
.
_conflict_cache
)
==
1
finally
:
TemporaryStorage
.
CONFLICT_CACHE_GCEVERY
=
old_gcevery
TemporaryStorage
.
CONFLICT_CACHE_MAXAGE
=
old_maxage
def
doreadconflict
(
self
,
db
,
mvcc
):
tm1
=
transaction
.
TransactionManager
()
tm1
=
transaction
.
TransactionManager
()
conn
=
db
.
open
(
transaction_manager
=
tm1
)
conn
=
db
.
open
(
transaction_manager
=
tm1
)
r1
=
conn
.
root
()
r1
=
conn
.
root
()
...
@@ -86,14 +75,42 @@ class TemporaryStorageTests(
...
@@ -86,14 +75,42 @@ class TemporaryStorageTests(
obj
.
child1
obj
.
child1
return
obj
return
obj
def
checkConflictCacheIsCleared
(
self
):
import
time
from
ZODB.tests.MinPO
import
MinPO
self
.
_set_conflict_cache
(
5
,
5
)
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
5
))
time
.
sleep
(
6
)
oid2
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid2
,
data
=
MinPO
(
10
))
oid3
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid3
,
data
=
MinPO
(
9
))
self
.
assertEqual
(
len
(
self
.
_storage
.
_conflict_cache
),
2
)
time
.
sleep
(
6
)
oid4
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid4
,
data
=
MinPO
(
11
))
self
.
assertEqual
(
len
(
self
.
_storage
.
_conflict_cache
),
1
)
def
checkWithMVCCDoesntRaiseReadConflict
(
self
):
def
checkWithMVCCDoesntRaiseReadConflict
(
self
):
from
ZODB.DB
import
DB
from
ZODB.tests.MinPO
import
MinPO
db
=
DB
(
self
.
_storage
)
db
=
DB
(
self
.
_storage
)
ob
=
self
.
doread
conflict
(
db
,
True
)
ob
=
self
.
_do_read_
conflict
(
db
,
True
)
self
.
assertEquals
(
ob
.
__class__
,
MinPO
)
self
.
assertEquals
(
ob
.
__class__
,
MinPO
)
self
.
assertEquals
(
getattr
(
ob
,
'child1'
,
MinPO
()).
value
,
'child1'
)
self
.
assertEquals
(
getattr
(
ob
,
'child1'
,
MinPO
()).
value
,
'child1'
)
self
.
failIf
(
getattr
(
ob
,
'child2'
,
None
))
self
.
failIf
(
getattr
(
ob
,
'child2'
,
None
))
def
checkLoadEx
(
self
):
def
checkLoadEx
(
self
):
from
ZODB.tests.MinPO
import
MinPO
oid
=
self
.
_storage
.
new_oid
()
oid
=
self
.
_storage
.
new_oid
()
self
.
_dostore
(
oid
,
data
=
MinPO
(
1
))
self
.
_dostore
(
oid
,
data
=
MinPO
(
1
))
loadp
,
loads
=
self
.
_storage
.
load
(
oid
,
'whatever'
)
loadp
,
loads
=
self
.
_storage
.
load
(
oid
,
'whatever'
)
...
@@ -104,25 +121,10 @@ class TemporaryStorageTests(
...
@@ -104,25 +121,10 @@ class TemporaryStorageTests(
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
makeSuite
(
TemporaryStorageTests
,
'check'
)
# Note: we follow the ZODB 'check' pattern here so that the base
suite2
=
unittest
.
makeSuite
(
Corruption
.
FileStorageCorruptTests
,
'check'
)
# class tests are picked up.
suite
.
addTest
(
suite2
)
return
unittest
.
TestSuite
((
return
suite
unittest
.
makeSuite
(
TemporaryStorageTests
,
'check'
),
# Why are we testing this here?
def
main
():
unittest
.
makeSuite
(
Corruption
.
FileStorageCorruptTests
,
'check'
),
alltests
=
test_suite
()
))
runner
=
unittest
.
TextTestRunner
(
verbosity
=
9
)
runner
.
run
(
alltests
)
def
debug
():
test_suite
().
debug
()
def
pdebug
():
import
pdb
pdb
.
run
(
'debug()'
)
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
globals
()[
sys
.
argv
[
1
]]()
else
:
main
()
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