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
Labels
Merge Requests
19
Merge Requests
19
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
36f7389a
Commit
36f7389a
authored
Nov 28, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share simulator code.
parent
d2c45581
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
93 deletions
+49
-93
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
..._accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
+48
-92
master/bt5/slapos_accounting/bt/revision
master/bt5/slapos_accounting/bt/revision
+1
-1
No files found.
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
View file @
36f7389a
...
@@ -35,18 +35,17 @@ class Simulator:
...
@@ -35,18 +35,17 @@ class Simulator:
open
(
self
.
outfile
,
'w'
).
write
(
repr
(
l
))
open
(
self
.
outfile
,
'w'
).
write
(
repr
(
l
))
return
self
.
to_return
return
self
.
to_return
def
simulateInstance_solveInvoicingGeneration
(
func
):
def
simulateByEditWorkflowMark
(
script_name
):
def
wrapper
(
func
):
@
functools
.
wraps
(
func
)
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
def
wrapped
(
self
,
*
args
,
**
kwargs
):
script_name
=
'Instance_solveInvoicingGeneration'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
script_name
,
'*args, **kwargs'
,
'*args, **kwargs'
,
'# Script body
\
n
'
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
"""context.portal_workflow.doActionFor(context, action='edit_action', comment='Visited by %s') """
%
script_name
)
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Instance_solveInvoicingGeneration') """
)
transaction
.
commit
()
transaction
.
commit
()
try
:
try
:
func
(
self
,
*
args
,
**
kwargs
)
func
(
self
,
*
args
,
**
kwargs
)
...
@@ -55,6 +54,31 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
...
@@ -55,6 +54,31 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by I
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
transaction
.
commit
()
return
wrapped
return
wrapped
return
wrapper
def
simulateByTitlewMark
(
script_name
):
def
wrapper
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""
if context.getTitle() == 'Not visited by %s':
context.setTitle('Visited by %s')
"""
%
(
script_name
,
script_name
))
transaction
.
commit
()
try
:
func
(
self
,
*
args
,
**
kwargs
)
finally
:
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
return
wrapped
return
wrapper
class
TestInstanceInvoicingAlarm
(
testSlapOSMixin
):
class
TestInstanceInvoicingAlarm
(
testSlapOSMixin
):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
@@ -102,7 +126,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
...
@@ -102,7 +126,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
@
simulate
Instance_solveInvoicingGeneration
@
simulate
ByEditWorkflowMark
(
'Instance_solveInvoicingGeneration'
)
def
test_alarm_findSoftwareInstance
(
self
):
def
test_alarm_findSoftwareInstance
(
self
):
new_id
=
self
.
generateNewId
()
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
...
@@ -124,7 +148,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
...
@@ -124,7 +148,7 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
'Visited by Instance_solveInvoicingGeneration'
,
'Visited by Instance_solveInvoicingGeneration'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
Instance_solveInvoicingGeneration
@
simulate
ByEditWorkflowMark
(
'Instance_solveInvoicingGeneration'
)
def
test_alarm_findSlaveInstance
(
self
):
def
test_alarm_findSlaveInstance
(
self
):
new_id
=
self
.
generateNewId
()
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
...
@@ -617,28 +641,6 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
...
@@ -617,28 +641,6 @@ class TestInstanceInvoicingAlarm(testSlapOSMixin):
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
1
)
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
2
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
2
)
def
simulateHostingSubscription_requestUpdateOpenSaleOrder
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
script_name
=
'HostingSubscription_requestUpdateOpenSaleOrder'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by HostingSubscription_requestUpdateOpenSaleOrder') """
)
transaction
.
commit
()
try
:
func
(
self
,
*
args
,
**
kwargs
)
finally
:
transaction
.
abort
()
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
return
wrapped
class
TestOpenSaleOrderAlarm
(
testSlapOSMixin
):
class
TestOpenSaleOrderAlarm
(
testSlapOSMixin
):
def
test_noOSO_newPerson
(
self
):
def
test_noOSO_newPerson
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
person
=
self
.
portal
.
person_module
.
template_member
\
...
@@ -686,7 +688,7 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
...
@@ -686,7 +688,7 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
self
.
assertTrue
(
all
([
q
in
open_sale_order
.
getCategoryList
()
\
self
.
assertTrue
(
all
([
q
in
open_sale_order
.
getCategoryList
()
\
for
q
in
open_sale_order_template
.
getCategoryList
()]))
for
q
in
open_sale_order_template
.
getCategoryList
()]))
@
simulate
HostingSubscription_requestUpdateOpenSaleOrder
@
simulate
ByEditWorkflowMark
(
'HostingSubscription_requestUpdateOpenSaleOrder'
)
def
test_alarm_HS_diverged
(
self
):
def
test_alarm_HS_diverged
(
self
):
subscription
=
self
.
portal
.
hosting_subscription_module
\
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
...
@@ -1092,31 +1094,8 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
...
@@ -1092,31 +1094,8 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
self
.
assertEqual
(
request_time_2
,
validated_line_2
.
getStartDate
())
self
.
assertEqual
(
request_time_2
,
validated_line_2
.
getStartDate
())
self
.
assertEqual
(
stop_date_2
,
validated_line_2
.
getStopDate
())
self
.
assertEqual
(
stop_date_2
,
validated_line_2
.
getStopDate
())
def
simulateSimulationMovement_buildSlapOS
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
script_name
=
'SimulationMovement_buildSlapOS'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
if context.getTitle() == 'Not visited by SimulationMovement_buildSlapOS':
context.setTitle('Visited by SimulationMovement_buildSlapOS')
"""
)
transaction
.
commit
()
try
:
func
(
self
,
*
args
,
**
kwargs
)
finally
:
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
return
wrapped
class
TestSlapOSTriggerBuildAlarm
(
testSlapOSMixin
):
class
TestSlapOSTriggerBuildAlarm
(
testSlapOSMixin
):
@
simulate
SimulationMovement_buildSlapOS
@
simulate
ByTitlewMark
(
'SimulationMovement_buildSlapOS'
)
def
test_SimulationMovement_withoutDelivery
(
self
):
def
test_SimulationMovement_withoutDelivery
(
self
):
applied_rule
=
self
.
portal
.
portal_simulation
.
newContent
(
applied_rule
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
)
portal_type
=
'Applied Rule'
)
...
@@ -1132,7 +1111,7 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
...
@@ -1132,7 +1111,7 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
'Visited by SimulationMovement_buildSlapOS'
,
'Visited by SimulationMovement_buildSlapOS'
,
simulation_movement
.
getTitle
())
simulation_movement
.
getTitle
())
@
simulate
SimulationMovement_buildSlapOS
@
simulate
ByTitlewMark
(
'SimulationMovement_buildSlapOS'
)
def
test_SimulationMovement_withDelivery
(
self
):
def
test_SimulationMovement_withDelivery
(
self
):
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
portal_type
=
'Sale Packing List'
)
...
@@ -1297,31 +1276,8 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
...
@@ -1297,31 +1276,8 @@ class TestSlapOSTriggerBuildAlarm(testSlapOSMixin):
if
os
.
path
.
exists
(
activate_simulator
):
if
os
.
path
.
exists
(
activate_simulator
):
os
.
unlink
(
activate_simulator
)
os
.
unlink
(
activate_simulator
)
def
simulateDelivery_manageBuildingCalculatingDelivery
(
func
):
@
functools
.
wraps
(
func
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
script_name
=
'Delivery_manageBuildingCalculatingDelivery'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
if context.getTitle() == 'Not visited by Delivery_manageBuildingCalculatingDelivery':
context.setTitle('Visited by Delivery_manageBuildingCalculatingDelivery')
"""
)
transaction
.
commit
()
try
:
func
(
self
,
*
args
,
**
kwargs
)
finally
:
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
return
wrapped
class
TestSlapOSManageBuildingCalculatingDeliveryAlarm
(
testSlapOSMixin
):
class
TestSlapOSManageBuildingCalculatingDeliveryAlarm
(
testSlapOSMixin
):
@
simulate
Delivery_manageBuildingCalculatingDelivery
@
simulate
ByTitlewMark
(
'Delivery_manageBuildingCalculatingDelivery'
)
def
_test
(
self
,
state
,
message
):
def
_test
(
self
,
state
,
message
):
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
title
=
'Not visited by Delivery_manageBuildingCalculatingDelivery'
,
title
=
'Not visited by Delivery_manageBuildingCalculatingDelivery'
,
...
...
master/bt5/slapos_accounting/bt/revision
View file @
36f7389a
171
172
\ No newline at end of file
\ 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