Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
1
Merge Requests
1
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
Cédric Le Ninivin
erp5
Commits
25042ac5
Commit
25042ac5
authored
Sep 25, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: speed up and clean up testTransactionalVariable
parent
e559ecd5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
39 deletions
+16
-39
product/ERP5Type/tests/testTransactionalVariable.py
product/ERP5Type/tests/testTransactionalVariable.py
+16
-39
No files found.
product/ERP5Type/tests/testTransactionalVariable.py
View file @
25042ac5
...
@@ -26,51 +26,37 @@
...
@@ -26,51 +26,37 @@
#
#
##############################################################################
##############################################################################
import
unittest
from
Testing.ZopeTestCase
import
TestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
LogInterceptor
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
class
TestTransactionalVariable
(
ERP5TypeTestCase
,
LogInterceptor
):
class
TestTransactionalVariable
(
TestCase
):
# Some helper methods
def
getTitle
(
self
):
return
"Transactional Variable"
def
getBusinessTemplateList
(
self
):
"""
Return the list of business templates.
"""
return
()
def
afterSetUp
(
self
):
from
transaction
import
abort
,
commit
self
.
login
()
def
test_01_DictInterface
(
self
):
def
test_01_DictInterface
(
self
):
"""Check if a transaction variable behaves in the same way as a dict. """
"""Check if a transaction variable behaves in the same way as a dict. """
tv
=
getTransactionalVariable
()
tv
=
getTransactionalVariable
()
self
.
assertNotEqual
(
tv
,
None
)
# Test frequently used dict methods. This does not cover everything,
# Test frequently used dict methods. This does not cover everything,
# but should be enough.
# but should be enough.
tv
.
clear
()
tv
.
clear
()
self
.
assertEqual
(
len
(
tv
),
0
)
self
.
assertEqual
(
len
(
tv
),
0
)
self
.
assertRaises
(
KeyError
,
tv
.
__getitem__
,
'toto'
)
with
self
.
assertRaises
(
KeyError
):
tv
[
'toto'
]
tv
[
'toto'
]
=
'titi'
tv
[
'toto'
]
=
'titi'
self
.
assertEqual
(
len
(
tv
),
1
)
self
.
assertEqual
(
len
(
tv
),
1
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assert
Equal
(
tv
.
get
(
'foo'
),
None
)
self
.
assert
IsNone
(
tv
.
get
(
'foo'
)
)
tv
.
setdefault
(
'foo'
,
'bar'
)
tv
.
setdefault
(
'foo'
,
'bar'
)
self
.
assertEqual
(
len
(
tv
),
2
)
self
.
assertEqual
(
len
(
tv
),
2
)
self
.
assertEqual
(
tv
[
'foo'
],
'bar'
)
self
.
assertEqual
(
tv
[
'foo'
],
'bar'
)
self
.
assert
True
(
'foo'
in
tv
)
self
.
assert
In
(
'foo'
,
tv
)
del
tv
[
'foo'
]
del
tv
[
'foo'
]
self
.
assert
False
(
'foo'
in
tv
)
self
.
assert
NotIn
(
'foo'
,
tv
)
self
.
assertEqual
(
len
(
tv
),
1
)
self
.
assertEqual
(
len
(
tv
),
1
)
def
test_02_Expiration
(
self
):
def
test_02_Expiration
(
self
):
...
@@ -78,8 +64,6 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
...
@@ -78,8 +64,6 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
transactions.
transactions.
"""
"""
tv
=
getTransactionalVariable
()
tv
=
getTransactionalVariable
()
self
.
assertNotEqual
(
tv
,
None
)
tv
.
clear
()
tv
.
clear
()
self
.
assertEqual
(
len
(
tv
),
0
)
self
.
assertEqual
(
len
(
tv
),
0
)
...
@@ -87,21 +71,19 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
...
@@ -87,21 +71,19 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
tv
[
'toto'
]
=
'titi'
tv
[
'toto'
]
=
'titi'
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
commit
()
self
.
commit
()
self
.
assert
False
(
'toto'
in
tv
)
self
.
assert
NotIn
(
'toto'
,
tv
)
# Abort and check.
# Abort and check.
tv
[
'toto'
]
=
'titi'
tv
[
'toto'
]
=
'titi'
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
abort
()
self
.
abort
()
self
.
assert
False
(
'toto'
in
tv
)
self
.
assert
NotIn
(
'toto'
,
tv
)
def
test_03_Durability
(
self
):
def
test_03_Durability
(
self
):
"""Check if a transaction variable does not disappear within the same
"""Check if a transaction variable does not disappear within the same
transaction.
transaction.
"""
"""
tv
=
getTransactionalVariable
()
tv
=
getTransactionalVariable
()
self
.
assertNotEqual
(
tv
,
None
)
tv
.
clear
()
tv
.
clear
()
self
.
assertEqual
(
len
(
tv
),
0
)
self
.
assertEqual
(
len
(
tv
),
0
)
...
@@ -109,19 +91,14 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
...
@@ -109,19 +91,14 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
# in order to detect the difference between their behaviors.
# in order to detect the difference between their behaviors.
tv
[
'toto'
]
=
'titi'
tv
[
'toto'
]
=
'titi'
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
portal
=
self
.
portal
app
=
self
.
app
vattr
=
'_v_erp5type_test_durability'
vattr
=
'_v_erp5type_test_durability'
setattr
(
portal
,
vattr
,
'dummy'
)
setattr
(
app
,
vattr
,
'dummy'
)
self
.
assertEqual
(
getattr
(
portal
,
vattr
),
'dummy'
)
self
.
assertEqual
(
getattr
(
app
,
vattr
),
'dummy'
)
# Force to minimize the connection cache so that volatile attributes
# Force to minimize the connection cache so that volatile attributes
# and unghostified objects are discarded.
# and unghostified objects are discarded.
portal
.
_p_jar
.
cacheMinimize
()
app
.
_p_jar
.
cacheMinimize
()
self
.
assert
True
(
'toto'
in
tv
)
self
.
assert
In
(
'toto'
,
tv
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
getattr
(
portal
,
vattr
,
None
),
None
)
self
.
assertIsNone
(
getattr
(
app
,
vattr
,
None
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestTransactionalVariable
))
return
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