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
Łukasz Nowak
slapos.core
Commits
c477c47e
Commit
c477c47e
authored
Jul 25, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: Remove tests from removed code.
parent
8a31bd2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
752 deletions
+10
-752
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+0
-606
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.xml
...portal_components/test.erp5.testSlapOSAccountingAlarm.xml
+10
-16
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.py
...ents/test.erp5.testSlapOSAccountingInteractionWorkflow.py
+0
-130
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
c477c47e
...
...
@@ -83,612 +83,6 @@ if context.getTitle() == 'Not visited by %s':
return
wrapped
return
wrapper
class
TestInstanceInvoicingAlarm
(
SlapOSTestCaseMixin
):
@
withAbort
def
test_noSaleOrderPackingList_newSoftwareInstance
(
self
):
"""
Be sure no delivery is created synchronously (break old code behaviour)
"""
self
.
software_instance_request_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
)
instance
=
self
.
portal
.
software_instance_module
.
template_software_instance
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance
.
edit
(
title
=
"TESTSI-%s"
%
self
.
generateNewId
())
instance
.
requestStart
(
**
self
.
software_instance_request_kw
)
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
@
withAbort
def
test_noSaleOrderPackingList_newSlaveInstance
(
self
):
"""
Be sure no delivery is created synchronously (break old code behaviour)
"""
self
.
slave_instance_request_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
True
,
)
instance
=
self
.
portal
.
software_instance_module
.
template_slave_instance
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance
.
edit
(
title
=
"TESTSI-%s"
%
self
.
generateNewId
())
instance
.
requestStart
(
**
self
.
slave_instance_request_kw
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
@
simulateByEditWorkflowMark
(
'Instance_solveInvoicingGeneration'
)
def
test_alarm_findSoftwareInstance
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
ssl_certificate
=
"foo"
,
ssl_key
=
"bar"
,
)
self
.
tic
()
self
.
portal
.
portal_alarms
\
.
slapos_instance_invoicing
\
.
activeSense
()
self
.
tic
()
self
.
assertEqual
(
'Visited by Instance_solveInvoicingGeneration'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulateByEditWorkflowMark
(
'Instance_solveInvoicingGeneration'
)
def
test_alarm_findSlaveInstance
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
self
.
tic
()
self
.
portal
.
portal_alarms
\
.
slapos_instance_invoicing
\
.
activeSense
()
self
.
tic
()
self
.
assertEqual
(
'Visited by Instance_solveInvoicingGeneration'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
withAbort
def
test_solved_instance
(
self
):
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
request_time
=
DateTime
(
'2012/01/01'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Simulated request instance'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroyed'
,
'time'
:
request_time
,
'action'
:
'request_instance'
})
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'solved'
)
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
@
withAbort
def
test_instance_in_draft_state
(
self
):
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Stay in draft'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'draft'
,
'time'
:
DateTime
(),
'action'
:
'foo_transition'
})
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertEqual
(
None
,
instance
.
getCausalityValue
())
@
withAbort
def
test_instance_in_unknown_state
(
self
):
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Stay in unknown state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'unknown_state'
,
'time'
:
DateTime
(),
'action'
:
'foo_transition'
})
self
.
assertRaises
(
AssertionError
,
instance
.
Instance_solveInvoicingGeneration
)
@
withAbort
def
test_instance_in_early_destroyed_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
start_date
=
instance
.
workflow_history
\
[
'instance_slap_interface_workflow'
][
0
][
'time'
]
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in destroyed state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
2
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
_
,
destroy_line
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
2
)
self
.
check_instance_movement
(
setup_line
,
instance
,
subscription
,
1
)
self
.
check_instance_movement
(
destroy_line
,
instance
,
subscription
,
1
)
def
check_instance_delivery
(
self
,
delivery
,
start_date
,
stop_date
,
person
,
line_count
):
packing_list_line
=
delivery
.
contentValues
(
portal_type
=
'Sale Packing List Line'
)
self
.
assertEqual
(
len
(
packing_list_line
),
line_count
)
self
.
assertEqual
(
delivery
.
getDestinationValue
(),
person
)
self
.
assertEqual
(
delivery
.
getDestinationDecisionValue
(),
person
)
self
.
assertEqual
(
delivery
.
getSpecialise
(),
'sale_trade_condition_module'
'/slapos_consumption_trade_condition'
)
self
.
assertEqual
(
delivery
.
getStopDate
(),
stop_date
)
self
.
assertEqual
(
delivery
.
getStartDate
(),
start_date
)
self
.
assertEqual
(
delivery
.
getSimulationState
(),
'delivered'
)
self
.
assertEqual
(
delivery
.
getCausalityState
(),
'building'
)
# Hardcoded, but, no idea how to not make it...
setup_line
=
([
None
]
+
[
x
for
x
in
packing_list_line
\
if
x
.
getResource
()
==
'service_module/slapos_instance_setup'
])[
-
1
]
destroy_line
=
([
None
]
+
[
x
for
x
in
packing_list_line
\
if
x
.
getResource
()
==
'service_module/slapos_instance_cleanup'
])[
-
1
]
update_line
=
([
None
]
+
[
x
for
x
in
packing_list_line
\
if
x
.
getResource
()
==
'service_module/slapos_instance_update'
])[
-
1
]
return
setup_line
,
update_line
,
destroy_line
def
check_instance_movement
(
self
,
movement
,
instance
,
subscription
,
quantity
):
self
.
assertEqual
(
movement
.
getQuantity
(),
quantity
)
self
.
assertSameSet
(
movement
.
getAggregateValueList
(),
[
instance
,
subscription
])
self
.
assertEqual
(
len
(
movement
.
contentValues
()),
0
)
@
withAbort
def
test_instance_create_non_destroyed_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
start_date
=
instance
.
workflow_history
\
[
'instance_slap_interface_workflow'
][
0
][
'time'
]
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in start state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'start_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
2
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
_
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
1
)
self
.
check_instance_movement
(
setup_line
,
instance
,
subscription
,
1
)
@
withAbort
def
test_instance_create_non_destroyed_with_update_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
start_date
=
instance
.
workflow_history
\
[
'instance_slap_interface_workflow'
][
0
][
'time'
]
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
1
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
2
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in start state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'start_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
4
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
_
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
2
)
self
.
check_instance_movement
(
setup_line
,
instance
,
subscription
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
2
)
@
withAbort
def
test_instance_create_destroyed_with_update_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
start_date
=
instance
.
workflow_history
\
[
'instance_slap_interface_workflow'
][
0
][
'time'
]
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
1
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
2
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in destroy state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
4
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
destroy_line
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
3
)
self
.
check_instance_movement
(
setup_line
,
instance
,
subscription
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
1
)
self
.
check_instance_movement
(
destroy_line
,
instance
,
subscription
,
1
)
@
withAbort
def
test_instance_update_non_destroyed_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
previous_delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
invoicing_synchronization_pointer
=
2
,
causality_value
=
previous_delivery
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
1
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
2
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in start state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'start_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
start_date
=
stop_date
-
1
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
4
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
_
,
update_line
,
destroy_line
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
2
)
@
withAbort
def
test_instance_update_destroyed_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
previous_delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
invoicing_synchronization_pointer
=
2
,
causality_value
=
previous_delivery
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
1
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'foo_state'
,
'time'
:
stop_date
-
2
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in start state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
start_date
=
stop_date
-
1
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
4
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
destroy_line
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
2
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
1
)
self
.
check_instance_movement
(
destroy_line
,
instance
,
subscription
,
1
)
@
withAbort
def
test_instance_update_already_destroyed
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
previous_delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
invoicing_synchronization_pointer
=
2
,
causality_value
=
previous_delivery
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
-
1
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Update'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
-
2
,
'action'
:
'foo_transition'
})
instance
.
workflow_history
[
'instance_slap_interface_workflow'
].
append
({
'comment'
:
'Directly in start state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
})
start_date
=
stop_date
-
1
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
4
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
_
=
\
self
.
check_instance_delivery
(
delivery
,
start_date
,
stop_date
,
person
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
2
)
@
withAbort
def
test_instance_in_only_destroyed_state
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
subscription
.
edit
(
reference
=
'TESTHS-%s'
%
self
.
generateNewId
(),
destination_section_value
=
person
)
instance
=
self
.
portal
.
software_instance_module
\
.
template_slave_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
new_id
=
self
.
generateNewId
()
instance
.
edit
(
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
specialise_value
=
subscription
,
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'diverged'
)
stop_date
=
DateTime
(
'2222/11/15'
)
instance
.
workflow_history
[
'instance_slap_interface_workflow'
]
=
[{
'comment'
:
'Directly in destroyed state'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
'destroy_requested'
,
'time'
:
stop_date
,
'action'
:
'foo_transition'
}]
instance
.
Instance_solveInvoicingGeneration
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
None
,
instance
.
getCausalityValue
())
self
.
assertEqual
(
1
,
instance
.
getInvoicingSynchronizationPointer
())
delivery
=
instance
.
getCausalityValue
()
setup_line
,
update_line
,
destroy_line
=
\
self
.
check_instance_delivery
(
delivery
,
stop_date
,
stop_date
,
person
,
1
)
self
.
check_instance_movement
(
update_line
,
instance
,
subscription
,
1
)
class
TestOpenSaleOrderAlarm
(
SlapOSTestCaseMixin
):
def
test_noOSO_newPerson
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.xml
View file @
c477c47e
...
...
@@ -47,22 +47,16 @@
<value>
<tuple>
<string>
W: 30, 10: Use of eval (eval-used)
</string>
<string>
W:350, 16: Unused variable \'update_line\' (unused-variable)
</string>
<string>
W:528, 20: Unused variable \'destroy_line\' (unused-variable)
</string>
<string>
W:588, 4: Unused variable \'setup_line\' (unused-variable)
</string>
<string>
W:649, 4: Unused variable \'setup_line\' (unused-variable)
</string>
<string>
W:688, 29: Unused variable \'destroy_line\' (unused-variable)
</string>
<string>
W:688, 4: Unused variable \'setup_line\' (unused-variable)
</string>
<string>
W:1364, 20: Use of eval (eval-used)
</string>
<string>
W:1365, 23: Use of eval (eval-used)
</string>
<string>
W:1386, 20: Use of eval (eval-used)
</string>
<string>
W:1387, 23: Use of eval (eval-used)
</string>
<string>
W:1452, 20: Use of eval (eval-used)
</string>
<string>
W:1453, 23: Use of eval (eval-used)
</string>
<string>
W:1462, 20: Use of eval (eval-used)
</string>
<string>
W:1463, 23: Use of eval (eval-used)
</string>
<string>
W:1526, 35: Use of eval (eval-used)
</string>
<string>
W:1527, 31: Use of eval (eval-used)
</string>
<string>
W:758, 20: Use of eval (eval-used)
</string>
<string>
W:759, 23: Use of eval (eval-used)
</string>
<string>
W:780, 20: Use of eval (eval-used)
</string>
<string>
W:781, 23: Use of eval (eval-used)
</string>
<string>
W:846, 20: Use of eval (eval-used)
</string>
<string>
W:847, 23: Use of eval (eval-used)
</string>
<string>
W:856, 20: Use of eval (eval-used)
</string>
<string>
W:857, 23: Use of eval (eval-used)
</string>
<string>
W:920, 35: Use of eval (eval-used)
</string>
<string>
W:921, 31: Use of eval (eval-used)
</string>
</tuple>
</value>
</item>
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingInteractionWorkflow.py
View file @
c477c47e
...
...
@@ -9,136 +9,6 @@ class TestSlapOSAccountingInteractionWorkflow(SlapOSTestCaseMixin):
def
beforeTearDown
(
self
):
transaction
.
abort
()
def
test_SlaveInstance_changePromise
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
instance
.
validate
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
request_kw
=
dict
(
software_release
=
'http://example.org'
,
software_type
=
'http://example.org'
,
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
True
,
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestStop
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestStart
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
bang
(
comment
=
'Test bang interaction'
,
bang_tree
=
False
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestDestroy
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
def
test_SlaveInstance_changePromiseInDivergeState
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
)
instance
.
validate
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
request_kw
=
dict
(
software_release
=
'http://example.org'
,
software_type
=
'http://example.org'
,
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
True
,
)
instance
.
requestStop
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
def
test_SoftwareInstance_changePromise
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
ssl_certificate
=
"foo"
,
ssl_key
=
"bar"
,
)
instance
.
validate
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
request_kw
=
dict
(
software_release
=
'http://example.org'
,
software_type
=
'http://example.org'
,
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestStop
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestStart
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
bang
(
comment
=
'Test bang interaction'
,
bang_tree
=
False
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
instance
.
converge
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'solved'
)
instance
.
requestDestroy
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
def
test_SoftwareInstance_changePromiseInDivergedState
(
self
):
new_id
=
self
.
generateNewId
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
title
=
"Instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
destination_reference
=
"TESTINST-%s"
%
new_id
,
ssl_certificate
=
"foo"
,
ssl_key
=
"bar"
,
)
instance
.
validate
()
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
request_kw
=
dict
(
software_release
=
'http://example.org'
,
software_type
=
'http://example.org'
,
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
)
instance
.
requestStop
(
**
request_kw
)
self
.
assertEqual
(
instance
.
getCausalityState
(),
'diverged'
)
def
_simulateHostingSubscription_calculateSubscriptionStartDate
(
self
,
date
):
script_name
=
'HostingSubscription_calculateSubscriptionStartDate'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
...
...
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