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
Jérome Perrin
slapos.core
Commits
9cdac07c
Commit
9cdac07c
authored
Jul 15, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting/testSlapOSAccountingAlarm: Clean up tests for rely on API to test alarm
parent
275b9026
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
156 deletions
+68
-156
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+48
-139
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.xml
...portal_components/test.erp5.testSlapOSAccountingAlarm.xml
+20
-17
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
9cdac07c
...
@@ -1225,24 +1225,6 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
...
@@ -1225,24 +1225,6 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
self
.
portal
.
OpenSaleOrder_updatePeriod
,
self
.
portal
.
OpenSaleOrder_updatePeriod
,
REQUEST
=
{})
REQUEST
=
{})
def
_simulatePerson_storeOpenSaleOrderJournal
(
self
):
script_name
=
'Person_storeOpenSaleOrderJournal'
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 Person_storeOpenSaleOrderJournal') """
)
transaction
.
commit
()
def
_dropPerson_storeOpenSaleOrderJournal
(
self
):
script_name
=
'Person_storeOpenSaleOrderJournal'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_updatePeriod_no_person
(
self
):
def
test_updatePeriod_no_person
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
open_order
.
OpenSaleOrder_updatePeriod
()
open_order
.
OpenSaleOrder_updatePeriod
()
...
@@ -1255,14 +1237,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
...
@@ -1255,14 +1237,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
destination_decision_value
=
person
,
destination_decision_value
=
person
,
)
)
self
.
_simulatePerson_storeOpenSaleOrderJournal
()
script_name
=
"Person_storeOpenSaleOrderJournal"
self
.
_simulateScript
(
script_name
)
try
:
try
:
open_order
.
OpenSaleOrder_updatePeriod
()
open_order
.
OpenSaleOrder_updatePeriod
()
finally
:
finally
:
self
.
_dropPerson_storeOpenSaleOrderJournal
()
self
.
_dropScript
(
script_name
)
self
.
assertEqual
(
self
.
assertScriptVisited
(
person
,
script_name
)
'Visited by Person_storeOpenSaleOrderJournal'
,
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_updatePeriod_invalidated
(
self
):
def
test_updatePeriod_invalidated
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
...
@@ -1273,74 +1254,43 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
...
@@ -1273,74 +1254,43 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by P
)
)
open_order
.
invalidate
()
open_order
.
invalidate
()
self
.
_simulatePerson_storeOpenSaleOrderJournal
()
script_name
=
"Person_storeOpenSaleOrderJournal"
self
.
_simulateScript
(
script_name
)
try
:
try
:
open_order
.
OpenSaleOrder_updatePeriod
()
open_order
.
OpenSaleOrder_updatePeriod
()
finally
:
finally
:
self
.
_dropPerson_storeOpenSaleOrderJournal
()
self
.
_dropScript
(
script_name
)
self
.
assertNotEqual
(
self
.
assertScriptNotVisited
(
person
,
script_name
)
'Visited by Person_storeOpenSaleOrderJournal'
,
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
_simulateOpenSaleOrder_updatePeriod
(
self
):
script_name
=
'OpenSaleOrder_updatePeriod'
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 OpenSaleOrder_updatePeriod') """
)
transaction
.
commit
()
def
_dropOpenSaleOrder_updatePeriod
(
self
):
script_name
=
'OpenSaleOrder_updatePeriod'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm
(
self
):
def
test_alarm
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
self
.
tic
()
self
.
tic
()
self
.
_simulateOpenSaleOrder_updatePeriod
()
script_name
=
"OpenSaleOrder_updatePeriod"
try
:
alarm
=
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
.
activeSense
()
self
.
tic
()
self
.
_test_alarm
(
finally
:
alarm
,
open_order
,
script_name
)
self
.
_dropOpenSaleOrder_updatePeriod
()
self
.
assertEqual
(
'Visited by OpenSaleOrder_updatePeriod'
,
open_order
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_invalidated
(
self
):
def
test_alarm_invalidated
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
open_order
.
invalidate
()
open_order
.
invalidate
()
self
.
tic
()
self
.
tic
()
self
.
_simulateOpenSaleOrder_updatePeriod
()
script_name
=
"OpenSaleOrder_updatePeriod"
try
:
alarm
=
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
.
activeSense
()
self
.
tic
()
self
.
_test_alarm_not_visited
(
finally
:
alarm
,
open_order
,
script_name
)
self
.
_dropOpenSaleOrder_updatePeriod
()
self
.
assertNotEqual
(
'Visited by OpenSaleOrder_updatePeriod'
,
open_order
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_no_line
(
self
):
def
test_alarm_no_line
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
self
.
tic
()
self
.
_simulateOpenSaleOrder_updatePeriod
()
script_name
=
"OpenSaleOrder_updatePeriod"
try
:
alarm
=
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
self
.
portal
.
portal_alarms
.
slapos_update_open_sale_order_period
.
activeSense
()
self
.
tic
()
self
.
_test_alarm_not_visited
(
finally
:
alarm
,
open_order
,
script_name
)
self
.
_dropOpenSaleOrder_updatePeriod
()
self
.
assertNotEqual
(
'Visited by OpenSaleOrder_updatePeriod'
,
open_order
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSReindexOpenSaleOrder
(
SlapOSTestCaseMixin
):
class
TestSlapOSReindexOpenSaleOrder
(
SlapOSTestCaseMixin
):
...
@@ -1354,8 +1304,7 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
...
@@ -1354,8 +1304,7 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
)
)
return
open_order
return
open_order
def
_simulateOpenSaleOrder_reindexIfIndexedBeforeLine
(
self
):
def
_simulateScript
(
self
,
script_name
):
script_name
=
'OpenSaleOrder_reindexIfIndexedBeforeLine'
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
,
...
@@ -1363,14 +1312,8 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
...
@@ -1363,14 +1312,8 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
'uid=None,*args, **kwargs'
,
'uid=None,*args, **kwargs'
,
'# Script body
\
n
'
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
"""portal_workflow = context.portal_workflow
open_order = context.portal_catalog.getResultValue(uid=uid)
document = context.portal_catalog.getResultValue(uid=uid)
portal_workflow.doActionFor(open_order, action='edit_action', comment='Visited by OpenSaleOrder_reindexIfIndexedBeforeLine') """
)
portal_workflow.doActionFor(document, action='edit_action', comment='Visited by %s') """
%
script_name
)
transaction
.
commit
()
def
_dropOpenSaleOrder_reindexIfIndexedBeforeLine
(
self
):
script_name
=
'OpenSaleOrder_reindexIfIndexedBeforeLine'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
transaction
.
commit
()
def
test_alarm
(
self
):
def
test_alarm
(
self
):
...
@@ -1380,28 +1323,20 @@ portal_workflow.doActionFor(open_order, action='edit_action', comment='Visited b
...
@@ -1380,28 +1323,20 @@ portal_workflow.doActionFor(open_order, action='edit_action', comment='Visited b
time
.
sleep
(
1
)
time
.
sleep
(
1
)
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
self
.
tic
()
self
.
tic
()
self
.
_simulateOpenSaleOrder_reindexIfIndexedBeforeLine
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
try
:
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
.
activeSense
()
self
.
tic
()
self
.
_test_alarm
(
finally
:
alarm
,
open_order
,
script_name
)
self
.
_dropOpenSaleOrder_reindexIfIndexedBeforeLine
()
self
.
assertEqual
(
'Visited by OpenSaleOrder_reindexIfIndexedBeforeLine'
,
open_order
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_no_line
(
self
):
def
test_alarm_no_line
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
self
.
tic
()
self
.
_simulateOpenSaleOrder_reindexIfIndexedBeforeLine
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
try
:
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
.
activeSense
()
self
.
tic
()
self
.
_test_alarm_not_visited
(
finally
:
alarm
,
open_order
,
script_name
)
self
.
_dropOpenSaleOrder_reindexIfIndexedBeforeLine
()
self
.
assertNotEqual
(
'Visited by OpenSaleOrder_reindexIfIndexedBeforeLine'
,
open_order
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
...
@@ -1412,49 +1347,23 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
...
@@ -1412,49 +1347,23 @@ class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
)
)
return
document
return
document
def
_simulateComputerConsumptionTioXMLFile_solveInvoicingGeneration
(
self
):
script_name
=
'ComputerConsumptionTioXMLFile_solveInvoicingGeneration'
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 ComputerConsumptionTioXMLFile_solveInvoicingGeneration') """
)
transaction
.
commit
()
def
_dropComputerConsumptionTioXMLFile_solveInvoicingGeneration
(
self
):
script_name
=
'ComputerConsumptionTioXMLFile_solveInvoicingGeneration'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm
(
self
):
def
test_alarm
(
self
):
document
=
self
.
createTioXMLFile
()
document
=
self
.
createTioXMLFile
()
document
.
submit
()
document
.
submit
()
self
.
tic
()
self
.
tic
()
self
.
_simulateComputerConsumptionTioXMLFile_solveInvoicingGeneration
()
try
:
script_name
=
"ComputerConsumptionTioXMLFile_solveInvoicingGeneration"
self
.
portal
.
portal_alarms
.
\
alarm
=
self
.
portal
.
portal_alarms
.
slapos_accounting_generate_packing_list_from_tioxml
slapos_accounting_generate_packing_list_from_tioxml
.
activeSense
()
self
.
tic
()
self
.
_test_alarm
(
finally
:
alarm
,
document
,
script_name
)
self
.
_dropComputerConsumptionTioXMLFile_solveInvoicingGeneration
()
self
.
assertEqual
(
'Visited by ComputerConsumptionTioXMLFile_solveInvoicingGeneration'
,
document
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_not_submitted
(
self
):
def
test_alarm_not_submitted
(
self
):
document
=
self
.
createTioXMLFile
()
document
=
self
.
createTioXMLFile
()
self
.
tic
()
self
.
tic
()
self
.
_simulateComputerConsumptionTioXMLFile_solveInvoicingGeneration
()
try
:
script_name
=
"ComputerConsumptionTioXMLFile_solveInvoicingGeneration"
self
.
portal
.
portal_alarms
.
\
alarm
=
self
.
portal
.
portal_alarms
.
slapos_accounting_generate_packing_list_from_tioxml
slapos_accounting_generate_packing_list_from_tioxml
.
activeSense
()
self
.
tic
()
self
.
_test_alarm_not_visited
(
finally
:
alarm
,
document
,
script_name
)
self
.
_dropComputerConsumptionTioXMLFile_solveInvoicingGeneration
()
self
.
assertNotEqual
(
'Visited by ComputerConsumptionTioXMLFile_solveInvoicingGeneration'
,
document
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.xml
View file @
9cdac07c
...
@@ -112,25 +112,28 @@
...
@@ -112,25 +112,28 @@
</record>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
</pickle>
<pickle>
<pickle>
<tuple>
<dictionary>
<none/>
<item>
<list>
<key>
<string>
_log
</string>
</key>
<dictionary>
<value>
<item>
<list>
<key>
<string>
action
</string>
</key>
<dictionary>
<value>
<string>
validate
</string>
</value>
<item>
</item>
<key>
<string>
action
</string>
</key>
<item>
<value>
<string>
validate
</string>
</value>
<key>
<string>
validation_state
</string>
</key>
</item>
<value>
<string>
validated
</string>
</value>
<item>
</item>
<key>
<string>
validation_state
</string>
</key>
</dictionary>
<value>
<string>
validated
</string>
</value>
</list>
</item>
<none/>
</dictionary>
</tuple>
</list>
</value>
</item>
</dictionary>
</pickle>
</pickle>
</record>
</record>
</ZopeData>
</ZopeData>
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