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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
8b63c868
Commit
8b63c868
authored
Feb 27, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: drop usage of createZODBPythonScript
parent
68e452dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
84 deletions
+39
-84
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.py
...ents/test.erp5.testSlapOSAccountingInteractionWorkflow.py
+36
-60
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.xml
...nts/test.erp5.testSlapOSAccountingInteractionWorkflow.xml
+3
-24
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.py
View file @
8b63c868
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
simulate
import
transaction
import
transaction
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
DateTime
import
DateTime
from
DateTime
import
DateTime
class
TestSlapOSAccountingInteractionWorkflow
(
SlapOSTestCaseMixin
):
class
TestSlapOSAccountingInteractionWorkflow
(
SlapOSTestCaseMixin
):
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
transaction
.
abort
()
transaction
.
abort
()
def
_simulateHostingSubscription_calculateSubscriptionStartDate
(
self
,
date
):
def
_test_HostingSubscription_fixConsistency
(
self
,
day
):
script_name
=
'HostingSubscription_calculateSubscriptionStartDate'
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
'
"""from DateTime import DateTime
return DateTime('%s') """
%
date
.
ISO
())
transaction
.
commit
()
def
_dropHostingSubscription_calculateSubscriptionStartDate
(
self
):
script_name
=
'HostingSubscription_calculateSubscriptionStartDate'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_HostingSubscription_fixConsistency
(
self
,
date
=
DateTime
(
'2012/01/15'
),
day
=
15
):
new_id
=
self
.
generateNewId
()
new_id
=
self
.
generateNewId
()
item
=
self
.
portal
.
hosting_subscription_module
.
newContent
(
item
=
self
.
portal
.
hosting_subscription_module
.
newContent
(
portal_type
=
'Hosting Subscription'
,
portal_type
=
'Hosting Subscription'
,
...
@@ -43,18 +23,29 @@ return DateTime('%s') """ % date.ISO())
...
@@ -43,18 +23,29 @@ return DateTime('%s') """ % date.ISO())
self
.
assertEqual
(
item
.
getPeriodicityMinute
(),
None
)
self
.
assertEqual
(
item
.
getPeriodicityMinute
(),
None
)
self
.
assertEqual
(
item
.
getPeriodicityMonthDay
(),
None
)
self
.
assertEqual
(
item
.
getPeriodicityMonthDay
(),
None
)
self
.
_simulateHostingSubscription_calculateSubscriptionStartDate
(
date
)
try
:
item
.
fixConsistency
()
item
.
fixConsistency
()
finally
:
self
.
_dropHostingSubscription_calculateSubscriptionStartDate
()
self
.
assertEqual
(
item
.
getPeriodicityHourList
(),
[
0
])
self
.
assertEqual
(
item
.
getPeriodicityHourList
(),
[
0
])
self
.
assertEqual
(
item
.
getPeriodicityMinuteList
(),
[
0
])
self
.
assertEqual
(
item
.
getPeriodicityMinuteList
(),
[
0
])
self
.
assertEqual
(
item
.
getPeriodicityMonthDay
(),
day
)
self
.
assertEqual
(
item
.
getPeriodicityMonthDay
(),
day
)
@
simulate
(
'HostingSubscription_calculateSubscriptionStartDate'
,
'*args, **kwargs'
,
"""# Script body
from DateTime import DateTime
return DateTime('%s')
"""
%
DateTime
(
'2012/01/15'
).
ISO
())
def
test_HostingSubscription_fixConsistency
(
self
):
self
.
_test_HostingSubscription_fixConsistency
(
15
)
@
simulate
(
'HostingSubscription_calculateSubscriptionStartDate'
,
'*args, **kwargs'
,
"""# Script body
from DateTime import DateTime
return DateTime('%s')
"""
%
DateTime
(
'2012/01/29'
).
ISO
())
def
test_HostingSubscription_fixConsistency_today_after_28
(
self
):
def
test_HostingSubscription_fixConsistency_today_after_28
(
self
):
self
.
test_HostingSubscription_fixConsistency
(
DateTime
(
'2012/01/29'
),
28
)
self
.
_test_HostingSubscription_fixConsistency
(
28
)
def
test_HostingSubscription_manageAfter
(
self
):
def
test_HostingSubscription_manageAfter
(
self
):
class
DummyTestException
(
Exception
):
class
DummyTestException
(
Exception
):
...
@@ -90,24 +81,12 @@ return DateTime('%s') """ % date.ISO())
...
@@ -90,24 +81,12 @@ return DateTime('%s') """ % date.ISO())
self
.
portal
.
portal_types
.
resetDynamicDocumentsOnceAtTransactionBoundary
()
self
.
portal
.
portal_types
.
resetDynamicDocumentsOnceAtTransactionBoundary
()
transaction
.
commit
()
transaction
.
commit
()
def
_simulateDelivery_calculate
(
self
):
@
simulate
(
'Delivery_calculate'
,
script_name
=
'Delivery_calculate'
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'
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""# Script body
"""portal_workflow = context.portal_workflow
portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Delivery_calculate') """
)
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by Delivery_calculate')
transaction
.
commit
()
"""
)
def
_dropDelivery_calculate
(
self
):
script_name
=
'Delivery_calculate'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
_test_calculate
(
self
,
new_id
,
newContent
,
**
new_kw
):
def
_test_calculate
(
self
,
new_id
,
newContent
,
**
new_kw
):
cancel_spl
=
newContent
(
**
new_kw
)
cancel_spl
=
newContent
(
**
new_kw
)
close_spl
=
newContent
(
**
new_kw
)
close_spl
=
newContent
(
**
new_kw
)
...
@@ -125,8 +104,6 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by D
...
@@ -125,8 +104,6 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by D
stop_spl
.
confirm
()
stop_spl
.
confirm
()
submit_spl
=
newContent
(
**
new_kw
)
submit_spl
=
newContent
(
**
new_kw
)
self
.
_simulateDelivery_calculate
()
try
:
cancel_spl
.
cancel
()
cancel_spl
.
cancel
()
close_spl
.
close
()
close_spl
.
close
()
confirm_spl
.
confirm
()
confirm_spl
.
confirm
()
...
@@ -137,8 +114,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by D
...
@@ -137,8 +114,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by D
start_spl
.
start
()
start_spl
.
start
()
stop_spl
.
stop
()
stop_spl
.
stop
()
submit_spl
.
submit
()
submit_spl
.
submit
()
finally
:
self
.
_dropDelivery_calculate
()
self
.
assertEqual
(
self
.
assertEqual
(
cancel_spl
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
],
cancel_spl
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
],
'Visited by Delivery_calculate'
)
'Visited by Delivery_calculate'
)
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.xml
View file @
8b63c868
...
@@ -6,12 +6,6 @@
...
@@ -6,12 +6,6 @@
</pickle>
</pickle>
<pickle>
<pickle>
<dictionary>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
default_reference
</string>
</key>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSAccountingInteractionWorkflow
</string>
</value>
<value>
<string>
testSlapOSAccountingInteractionWorkflow
</string>
</value>
...
@@ -55,28 +49,13 @@
...
@@ -55,28 +49,13 @@
<item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<key>
<string>
workflow_history
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
</pickle>
...
@@ -89,7 +68,7 @@
...
@@ -89,7 +68,7 @@
<item>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
...
@@ -98,7 +77,7 @@
...
@@ -98,7 +77,7 @@
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
</pickle>
...
...
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