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
Eric Zheng
slapos.core
Commits
9ebe206b
Commit
9ebe206b
authored
Nov 13, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover the most basic functionality of Open Sale Order update.
parent
6bfadfeb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
1 deletion
+141
-1
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
...apOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
+140
-0
master/bt5/slapos_accounting/bt/revision
master/bt5/slapos_accounting/bt/revision
+1
-1
No files found.
master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingSlapOSRequestUpdateHostingSubscriptionOpenSaleOrderAlarm.py
View file @
9ebe206b
...
...
@@ -10,6 +10,8 @@ import functools
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.SlapOS.tests.testSlapOSMixin
import
\
testSlapOSMixin
from
DateTime
import
DateTime
from
Products.ERP5Type.DateUtils
import
addToDate
def
simulateHostingSubscription_requestUpdateOpenSaleOrder
(
func
):
@
functools
.
wraps
(
func
)
...
...
@@ -197,3 +199,141 @@ class TestOpenSaleOrderAlarm(testSlapOSMixin):
self
.
assertNotEqual
(
'Visited by HostingSubscription_requestUpdateOpenSaleOrder'
,
subscription
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestHostingSubscription_requestUpdateOpenSaleOrder
(
testSlapOSMixin
):
def
test_empty_HostingSubscription
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
tic
()
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section
=
person
.
getRelativeUrl
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
subscription
,
'validated'
)
self
.
tic
()
subscription
.
HostingSubscription_requestUpdateOpenSaleOrder
()
self
.
tic
()
open_sale_order_list
=
self
.
portal
.
portal_catalog
(
portal_type
=
'Open Sale Order'
,
default_destination_section_uid
=
person
.
getUid
()
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_list
))
open_sale_order
=
open_sale_order_list
[
0
].
getObject
()
self
.
assertEqual
(
'validated'
,
open_sale_order
.
getValidationState
())
open_sale_order_line_list
=
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_line_list
))
line
=
open_sale_order_line_list
[
0
].
getObject
()
self
.
assertEqual
(
subscription
.
getRelativeUrl
(),
line
.
getAggregate
())
self
.
assertEqual
(
self
.
portal
.
portal_preferences
\
.
getPreferredInstanceSubscriptionResource
(),
line
.
getResource
())
self
.
assertEqual
(
None
,
line
.
getStartDate
())
def
test_usualLifetime_HostingSubscription
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
tic
()
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
title
=
'Test Title %s'
%
self
.
generateNewId
(),
destination_section
=
person
.
getRelativeUrl
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
subscription
,
'validated'
)
request_time
=
DateTime
(
'2012/01/01'
)
subscription
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Simulated request instance'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'start_requested'
,
'time'
:
request_time
,
'action'
:
'request_instance'
})
self
.
tic
()
subscription
.
HostingSubscription_requestUpdateOpenSaleOrder
()
self
.
tic
()
open_sale_order_list
=
self
.
portal
.
portal_catalog
(
portal_type
=
'Open Sale Order'
,
default_destination_section_uid
=
person
.
getUid
()
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_list
))
open_sale_order
=
open_sale_order_list
[
0
].
getObject
()
self
.
assertEqual
(
'validated'
,
open_sale_order
.
getValidationState
())
open_sale_order_line_list
=
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_line_list
))
line
=
open_sale_order_line_list
[
0
].
getObject
()
self
.
assertEqual
(
subscription
.
getRelativeUrl
(),
line
.
getAggregate
())
self
.
assertEqual
(
self
.
portal
.
portal_preferences
\
.
getPreferredInstanceSubscriptionResource
(),
line
.
getResource
())
self
.
assertEqual
(
request_time
,
line
.
getStartDate
())
destroy_time
=
DateTime
(
'2012/02/01'
)
subscription
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Simulated request instance'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
destroy_time
,
'action'
:
'request_destroy'
})
self
.
tic
()
subscription
.
HostingSubscription_requestUpdateOpenSaleOrder
()
self
.
tic
()
open_sale_order_list
=
self
.
portal
.
portal_catalog
(
portal_type
=
'Open Sale Order'
,
default_destination_section_uid
=
person
.
getUid
()
)
self
.
assertEqual
(
2
,
len
(
open_sale_order_list
))
validated_open_sale_order_list
=
[
q
for
q
in
open_sale_order_list
if
q
.
getValidationState
()
==
'validated'
]
archived_open_sale_order_list
=
[
q
for
q
in
open_sale_order_list
if
q
.
getValidationState
()
==
'archived'
]
self
.
assertEqual
(
1
,
len
(
validated_open_sale_order_list
))
self
.
assertEqual
(
1
,
len
(
archived_open_sale_order_list
))
validated_open_sale_order
=
validated_open_sale_order_list
[
0
].
getObject
()
archived_open_sale_order
=
archived_open_sale_order_list
[
0
]
\
.
getObject
()
self
.
assertEqual
(
open_sale_order
.
getRelativeUrl
(),
archived_open_sale_order
.
getRelativeUrl
())
validated_line_list
=
validated_open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
archived_line_list
=
archived_open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
0
,
len
(
validated_line_list
))
self
.
assertEqual
(
1
,
len
(
archived_line_list
))
archived_line
=
archived_line_list
[
0
].
getObject
()
self
.
assertEqual
(
line
.
getRelativeUrl
(),
archived_line
.
getRelativeUrl
())
self
.
assertEqual
(
subscription
.
getRelativeUrl
(),
archived_line
.
getAggregate
())
self
.
assertEqual
(
self
.
portal
.
portal_preferences
\
.
getPreferredInstanceSubscriptionResource
(),
archived_line
.
getResource
())
self
.
assertEqual
(
request_time
,
archived_line
.
getStartDate
())
# calculate stop date to be after now, begin with start date with precision
# of month
stop_date
=
request_time
now
=
DateTime
()
while
stop_date
<
now
:
stop_date
=
addToDate
(
stop_date
,
to_add
=
{
'month'
:
1
})
self
.
assertEqual
(
stop_date
,
archived_line
.
getStopDate
())
master/bt5/slapos_accounting/bt/revision
View file @
9ebe206b
8
9
\ 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