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
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
Hardik Juneja
erp5
Commits
5a5cc985
Commit
5a5cc985
authored
Mar 27, 2017
by
Hardik Juneja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix erp5 type live testing suite
parent
5cf1ee58
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
5 deletions
+85
-5
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
+84
-5
product/ERP5Type/tests/ProcessingNodeTestCase.py
product/ERP5Type/tests/ProcessingNodeTestCase.py
+1
-0
No files found.
product/ERP5Type/tests/ERP5TypeLiveTestCase.py
View file @
5a5cc985
...
@@ -32,6 +32,7 @@ import sys
...
@@ -32,6 +32,7 @@ import sys
import
imp
import
imp
import
re
import
re
import
thread
import
thread
import
weakref
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
PortalTestCase
,
user_name
from
Testing.ZopeTestCase
import
PortalTestCase
,
user_name
...
@@ -42,6 +43,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import \
...
@@ -42,6 +43,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import \
ERP5TypeTestCaseMixin
,
ERP5TypeTestCase
ERP5TypeTestCaseMixin
,
ERP5TypeTestCase
from
glob
import
glob
from
glob
import
glob
import
transaction
import
transaction
from
functools
import
wraps
from
zLOG
import
LOG
,
DEBUG
,
INFO
from
zLOG
import
LOG
,
DEBUG
,
INFO
...
@@ -49,7 +51,80 @@ from zLOG import LOG, DEBUG, INFO
...
@@ -49,7 +51,80 @@ from zLOG import LOG, DEBUG, INFO
# Tic doesn't need help as TimerService is running
# Tic doesn't need help as TimerService is running
from
Products.ERP5Type.tests
import
ProcessingNodeTestCase
as
\
from
Products.ERP5Type.tests
import
ProcessingNodeTestCase
as
\
ProcessingNodeTestCaseModule
ProcessingNodeTestCaseModule
ProcessingNodeTestCaseModule
.
patchActivityTool
=
lambda
:
None
class
Patch
(
object
):
"""
Patch attributes and revert later automatically.
Usage:
with Patch(someObject, attrToPatch=newValue, [otherAttr=...]) as patch:
[... code that runs with patches ...]
[... code that runs without patch ...]
' as patch' is optional: 'patch.revert()' can be used to revert patches
in the middle of the 'with' clause.
"""
applied
=
False
def
__new__
(
cls
,
patched
,
**
patch
):
if
patch
:
return
object
.
__new__
(
cls
)
def
patch
(
func
):
self
=
cls
(
patched
,
**
{
func
.
__name__
:
func
})
self
.
apply
()
return
self
return
patch
def
__init__
(
self
,
patched
,
**
patch
):
(
name
,
patch
),
=
patch
.
iteritems
()
self
.
_patched
=
patched
self
.
_name
=
name
if
callable
(
patch
):
wrapped
=
getattr
(
patched
,
name
,
None
)
func
=
patch
patch
=
lambda
*
args
,
**
kw
:
func
(
wrapped
,
*
args
,
**
kw
)
if
callable
(
wrapped
):
patch
=
wraps
(
wrapped
)(
patch
)
self
.
_patch
=
patch
try
:
orig
=
patched
.
__dict__
[
name
]
self
.
_revert
=
lambda
:
setattr
(
patched
,
name
,
orig
)
except
KeyError
:
self
.
_revert
=
lambda
:
delattr
(
patched
,
name
)
def
apply
(
self
):
assert
not
self
.
applied
setattr
(
self
.
_patched
,
self
.
_name
,
self
.
_patch
)
self
.
applied
=
True
def
revert
(
self
):
del
self
.
applied
self
.
_revert
()
def
__del__
(
self
):
if
self
.
applied
:
self
.
revert
()
def
__enter__
(
self
):
self
.
apply
()
return
weakref
.
proxy
(
self
)
def
__exit__
(
self
,
t
,
v
,
tb
):
self
.
__del__
()
from
Products.CMFActivity.ActivityTool
import
ActivityTool
def
tic
(
self
,
orig
,
processing_node
=
1
,
force
=
0
):
#import pdb; pdb.set_trace();
currentNode
=
self
.
getCurrentNode
()
processing_node_list
=
self
.
getProcessingNodeList
()
if
currentNode
in
processing_node_list
:
orig
(
processing_node
,
force
)
else
:
# Sleep between each distribute.
time
.
sleep
(
0.3
)
transaction
.
begin
()
_request_server_url
=
None
_request_server_url
=
None
...
@@ -239,7 +314,11 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **
...
@@ -239,7 +314,11 @@ def runLiveTest(test_list, verbosity=1, stream=None, request_server_url=None, **
# original SecurityManager is restored
# original SecurityManager is restored
from
AccessControl.SecurityManagement
import
getSecurityManager
,
setSecurityManager
from
AccessControl.SecurityManagement
import
getSecurityManager
,
setSecurityManager
sm
=
getSecurityManager
()
sm
=
getSecurityManager
()
with
Patch
(
ActivityTool
,
tic
=
tic
)
as
patch
:
try
:
try
:
# patch
result
=
TestRunner
(
stream
=
output
,
verbosity
=
verbosity
).
run
(
suite
)
result
=
TestRunner
(
stream
=
output
,
verbosity
=
verbosity
).
run
(
suite
)
finally
:
finally
:
setSecurityManager
(
sm
)
setSecurityManager
(
sm
)
# unpatch
patch
.
revert
()
product/ERP5Type/tests/ProcessingNodeTestCase.py
View file @
5a5cc985
...
@@ -222,6 +222,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
...
@@ -222,6 +222,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
getMessageList
=
portal_activities
.
getMessageList
getMessageList
=
portal_activities
.
getMessageList
message_list
=
getMessageList
()
message_list
=
getMessageList
()
message_count
=
len
(
message_list
)
message_count
=
len
(
message_list
)
import
pdb
;
pdb
.
set_trace
()
while
message_count
and
not
stop_condition
(
message_list
):
while
message_count
and
not
stop_condition
(
message_list
):
if
verbose
and
old_message_count
!=
message_count
:
if
verbose
and
old_message_count
!=
message_count
:
ZopeTestCase
.
_print
(
' %i'
%
message_count
)
ZopeTestCase
.
_print
(
' %i'
%
message_count
)
...
...
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