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
Léo-Paul Géneau
slapos.core
Commits
c2a73196
Commit
c2a73196
authored
Feb 06, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: Drop _simulateScript
parent
3eeae716
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
37 deletions
+40
-37
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+40
-37
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
c2a73196
...
@@ -1276,6 +1276,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
...
@@ -1276,6 +1276,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
open_order
.
OpenSaleOrder_updatePeriod
()
open_order
.
OpenSaleOrder_updatePeriod
()
@
simulateByEditWorkflowMark
(
'Person_storeOpenSaleOrderJournal'
)
def
test_updatePeriod_validated
(
self
):
def
test_updatePeriod_validated
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
person
=
self
.
portal
.
person_module
.
template_member
\
person
=
self
.
portal
.
person_module
.
template_member
\
...
@@ -1284,14 +1285,12 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
...
@@ -1284,14 +1285,12 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value
=
person
,
destination_decision_value
=
person
,
)
)
script_name
=
"Person_storeOpenSaleOrderJournal"
open_order
.
OpenSaleOrder_updatePeriod
()
self
.
_simulateScript
(
script_name
)
self
.
assertEqual
(
try
:
'Visited by Person_storeOpenSaleOrderJournal'
,
open_order
.
OpenSaleOrder_updatePeriod
()
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptVisited
(
person
,
script_name
)
@
simulateByEditWorkflowMark
(
'Person_storeOpenSaleOrderJournal'
)
def
test_updatePeriod_invalidated
(
self
):
def
test_updatePeriod_invalidated
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
person
=
self
.
portal
.
person_module
.
template_member
\
person
=
self
.
portal
.
person_module
.
template_member
\
...
@@ -1300,14 +1299,11 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
...
@@ -1300,14 +1299,11 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value
=
person
,
destination_decision_value
=
person
,
)
)
open_order
.
invalidate
()
open_order
.
invalidate
()
open_order
.
OpenSaleOrder_updatePeriod
()
script_name
=
"Person_storeOpenSaleOrderJournal"
self
.
assertNotEqual
(
self
.
_simulateScript
(
script_name
)
'Visited by Person_storeOpenSaleOrderJournal'
,
try
:
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
open_order
.
OpenSaleOrder_updatePeriod
()
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptNotVisited
(
person
,
script_name
)
def
test_alarm
(
self
):
def
test_alarm
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
...
@@ -1351,39 +1347,46 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
...
@@ -1351,39 +1347,46 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
)
)
return
open_order
return
open_order
def
_simulateScript
(
self
,
script_name
,
fake_return
=
"False"
):
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
,
'uid=None,*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
document = context.portal_catalog.getResultValue(uid=uid)
portal_workflow.doActionFor(document, action='edit_action', comment='Visited by %s') """
%
script_name
)
transaction
.
commit
()
def
test_alarm
(
self
):
def
test_alarm
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
self
.
tic
()
# Jut wait a bit so the line has a different timestamp > 1 sec.
# Jut wait a bit so the line has a different timestamp > 1 sec.
time
.
sleep
(
1
)
time
.
sleep
(
1
)
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
open_order
_line
=
open_order
.
newContent
(
portal_type
=
"Open Sale Order Line"
)
self
.
tic
()
self
.
tic
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
order
=
self
.
portal
.
portal_catalog
(
uid
=
open_order
.
getUid
(),
self
.
_test_alarm
(
select_dict
=
{
'indexation_timestamp'
:
None
})[
0
]
alarm
,
open_order
,
script_name
)
line
=
self
.
portal
.
portal_catalog
(
uid
=
open_order_line
.
getUid
(),
select_dict
=
{
'indexation_timestamp'
:
None
})[
0
]
self
.
assertTrue
(
order
.
indexation_timestamp
<
line
.
indexation_timestamp
)
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
.
activeSense
()
self
.
tic
()
order
=
self
.
portal
.
portal_catalog
(
uid
=
open_order
.
getUid
(),
select_dict
=
{
'indexation_timestamp'
:
None
})[
0
]
line
=
self
.
portal
.
portal_catalog
(
uid
=
open_order_line
.
getUid
(),
select_dict
=
{
'indexation_timestamp'
:
None
})[
0
]
self
.
assertTrue
(
order
.
indexation_timestamp
>
line
.
indexation_timestamp
,
"%s %s"
%
(
order
.
indexation_timestamp
,
line
.
indexation_timestamp
))
def
test_alarm_no_line
(
self
):
def
test_alarm_no_line
(
self
):
open_order
=
self
.
createOpenOrder
()
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
self
.
tic
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
# Rather them test the alarm with fake script, directly
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
# test the ERP5Site_zGetOpenOrderWithModifiedLineUid code.
open_order_with_modified_line_uid_list
=
[
i
.
uid
for
i
in
\
self
.
_test_alarm_not_visited
(
self
.
portal
.
ERP5Site_zGetOpenOrderWithModifiedLineUid
()]
alarm
,
open_order
,
script_name
)
self
.
assertNotIn
(
open_order
.
getUid
(),
open_order_with_modified_line_uid_list
)
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
...
...
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