Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Lu Xu
slapos.core
Commits
ca20a44f
Commit
ca20a44f
authored
Nov 15, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check SimulationMovement_buildSlapOS with simulator.
parent
49159012
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
1 deletion
+113
-1
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSTriggerBuildAlarm.py
...mplateItem/testSlapOSAccountingSlapOSTriggerBuildAlarm.py
+112
-0
master/bt5/slapos_accounting/bt/revision
master/bt5/slapos_accounting/bt/revision
+1
-1
No files found.
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSTriggerBuildAlarm.py
View file @
ca20a44f
...
...
@@ -7,10 +7,40 @@
import
transaction
import
functools
import
os
import
tempfile
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.SlapOS.tests.testSlapOSMixin
import
\
testSlapOSMixin
def
withAbort
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
try
:
func
(
self
,
*
args
,
**
kwargs
)
finally
:
transaction
.
abort
()
return
wrapped
class
Simulator
:
def
__init__
(
self
,
outfile
,
method
,
to_return
=
None
):
self
.
outfile
=
outfile
self
.
method
=
method
self
.
to_return
=
to_return
def
__call__
(
self
,
*
args
,
**
kwargs
):
"""Simulation Method"""
old
=
open
(
self
.
outfile
,
'r'
).
read
()
if
old
:
l
=
eval
(
old
)
else
:
l
=
[]
l
.
append
({
'recmethod'
:
self
.
method
,
'recargs'
:
args
,
'reckwargs'
:
kwargs
})
open
(
self
.
outfile
,
'w'
).
write
(
repr
(
l
))
return
self
.
to_return
def
simulateSimulationMovement_buildSlapOS
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -70,3 +100,85 @@ class TestAlarm(testSlapOSMixin):
self
.
assertNotEqual
(
'Not visited by SimulationMovement_buildSlapOS'
,
simulation_movement
.
getTitle
())
@
withAbort
def
test_SimulationMovement_buildSlapOS
(
self
):
business_process
=
self
.
portal
.
business_process_module
.
newContent
(
portal_type
=
'Business Process'
)
root_business_link
=
business_process
.
newContent
(
portal_type
=
'Business Link'
)
business_link
=
business_process
.
newContent
(
portal_type
=
'Business Link'
)
root_applied_rule
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
)
simulation_movement
=
root_applied_rule
.
newContent
(
causality
=
root_business_link
.
getRelativeUrl
(),
portal_type
=
'Simulation Movement'
)
applied_rule
=
simulation_movement
.
newContent
(
portal_type
=
'Applied Rule'
)
lower_simulation_movement
=
applied_rule
.
newContent
(
causality
=
business_link
.
getRelativeUrl
(),
portal_type
=
'Simulation Movement'
)
build_simulator
=
tempfile
.
mkstemp
()[
1
]
activate_simulator
=
tempfile
.
mkstemp
()[
1
]
try
:
from
Products.CMFActivity.ActiveObject
import
ActiveObject
ActiveObject
.
original_activate
=
ActiveObject
.
activate
ActiveObject
.
activate
=
Simulator
(
activate_simulator
,
'activate'
,
root_applied_rule
)
from
Products.ERP5.Document.BusinessLink
import
BusinessLink
BusinessLink
.
original_build
=
BusinessLink
.
build
BusinessLink
.
build
=
Simulator
(
build_simulator
,
'build'
)
simulation_movement
.
SimulationMovement_buildSlapOS
(
tag
=
'root_tag'
)
build_value
=
eval
(
open
(
build_simulator
).
read
())
activate_value
=
eval
(
open
(
activate_simulator
).
read
())
self
.
assertEqual
([{
'recmethod'
:
'build'
,
'recargs'
:
(),
'reckwargs'
:
{
'path'
:
'%s/%%'
%
root_applied_rule
.
getPath
(),
'activate_kw'
:
{
'tag'
:
'root_tag'
}}}],
build_value
)
self
.
assertEqual
([{
'recmethod'
:
'activate'
,
'recargs'
:
(),
'reckwargs'
:
{
'tag'
:
'build_in_progress_%s_%s'
%
(
root_business_link
.
getUid
(),
root_applied_rule
.
getUid
()),
'after_tag'
:
'root_tag'
,
'activity'
:
'SQLQueue'
}}],
activate_value
)
open
(
build_simulator
,
'w'
).
truncate
()
open
(
activate_simulator
,
'w'
).
truncate
()
lower_simulation_movement
.
SimulationMovement_buildSlapOS
(
tag
=
'lower_tag'
)
build_value
=
eval
(
open
(
build_simulator
).
read
())
activate_value
=
eval
(
open
(
activate_simulator
).
read
())
self
.
assertEqual
([{
'recmethod'
:
'build'
,
'recargs'
:
(),
'reckwargs'
:
{
'path'
:
'%s/%%'
%
root_applied_rule
.
getPath
(),
'activate_kw'
:
{
'tag'
:
'lower_tag'
}}}],
build_value
)
self
.
assertEqual
([{
'recmethod'
:
'activate'
,
'recargs'
:
(),
'reckwargs'
:
{
'tag'
:
'build_in_progress_%s_%s'
%
(
business_link
.
getUid
(),
root_applied_rule
.
getUid
()),
'after_tag'
:
'lower_tag'
,
'activity'
:
'SQLQueue'
}}],
activate_value
)
finally
:
ActiveObject
.
activate
=
ActiveObject
.
original_activate
delattr
(
ActiveObject
,
'original_activate'
)
BusinessLink
.
build
=
BusinessLink
.
original_build
delattr
(
BusinessLink
,
'original_build'
)
if
os
.
path
.
exists
(
build_simulator
):
os
.
unlink
(
build_simulator
)
if
os
.
path
.
exists
(
activate_simulator
):
os
.
unlink
(
activate_simulator
)
master/bt5/slapos_accounting/bt/revision
View file @
ca20a44f
36
\ No newline at end of file
37
\ No newline at end of file
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