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
2687799b
Commit
2687799b
authored
Feb 13, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: testSlapOSAccountingBuilder
Recreate the expected organisation. Drop the aggregated builder test
parent
2bd65de0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
205 deletions
+11
-205
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
...ortal_components/test.erp5.testSlapOSAccountingBuilder.py
+8
-181
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.xml
...rtal_components/test.erp5.testSlapOSAccountingBuilder.xml
+3
-24
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
View file @
2687799b
...
...
@@ -14,6 +14,13 @@ def convertCategoryList(base, l):
return
[
'%s/%s'
%
(
base
,
q
)
for
q
in
l
]
class
TestSlapOSSalePackingListBuilder
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
super
(
TestSlapOSSalePackingListBuilder
,
self
).
afterSetUp
()
self
.
expected_slapos_organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
"Organisation"
,
title
=
"testSlapOSAccountingBuilder"
).
getRelativeUrl
()
def
checkSimulationMovement
(
self
,
simulation_movement
):
self
.
assertEqual
(
1.0
,
simulation_movement
.
getDeliveryRatio
())
self
.
assertEqual
(
0.0
,
simulation_movement
.
getDeliveryError
())
...
...
@@ -152,6 +159,7 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
self
.
checkDelivery
(
simulation_movement_2
,
delivery_2
,
**
delivery_kw
)
class
TestSlapOSSaleInvoiceBuilder
(
TestSlapOSSalePackingListBuilder
):
def
test
(
self
,
causality1
=
None
,
causality2
=
None
):
# pylint: disable=arguments-differ
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
...
...
@@ -1826,184 +1834,3 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self
.
assertEqual
(
invoice_2
.
getRelativeUrl
(),
model_line_2_tax_bis
.
getParentValue
().
getRelativeUrl
())
class
TestSlapOSAggregatedDeliveryBuilder
(
SlapOSTestCaseMixin
):
def
emptyBuild
(
self
,
**
kw
):
delivery_list
=
self
.
_build
(
**
kw
)
self
.
assertSameSet
([],
delivery_list
)
return
delivery_list
def
fullBuild
(
self
,
**
kw
):
delivery_list
=
self
.
_build
(
**
kw
)
self
.
assertNotEqual
([],
delivery_list
)
return
delivery_list
def
_build
(
self
,
**
kw
):
return
self
.
portal
.
portal_orders
.
slapos_aggregated_delivery_builder
.
build
(
**
kw
)
def
_createDelivery
(
self
,
**
kwargs
):
delivery
=
self
.
portal
.
restrictedTraverse
(
self
.
portal
.
portal_preferences
.
getPreferredInstanceDeliveryTemplate
()
).
Base_createCloneDocument
(
batch_mode
=
1
)
delivery
.
edit
(
**
kwargs
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery
,
'delivered'
)
return
delivery
def
_addDeliveryLine
(
self
,
delivery
,
**
kwargs
):
kwargs
.
setdefault
(
'portal_type'
,
'Sale Packing List Line'
)
kwargs
.
setdefault
(
'quantity'
,
1.0
)
kwargs
.
setdefault
(
'resource'
,
'service_module/slapos_instance_setup'
)
kwargs
.
setdefault
(
'price'
,
0.0
)
delivery_line
=
delivery
.
newContent
(
**
kwargs
)
return
delivery_line
def
test
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery
=
self
.
_createDelivery
(
destination_value
=
person
,
destination_decision_value
=
person
)
delivery_line
=
self
.
_addDeliveryLine
(
delivery
)
self
.
tic
()
delivery_list
=
self
.
fullBuild
(
uid
=
delivery_line
.
getUid
())
self
.
assertEqual
(
1
,
len
(
delivery_list
))
built_delivery
=
delivery_list
[
0
]
self
.
assertEqual
(
delivery_line
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
'confirmed'
,
built_delivery
.
getSimulationState
())
self
.
assertEqual
(
'building'
,
built_delivery
.
getCausalityState
())
self
.
assertSameSet
([
'destination/%s'
%
person
.
getRelativeUrl
(),
'destination_decision/%s'
%
person
.
getRelativeUrl
(),
'destination_section/%s'
%
person
.
getRelativeUrl
(),
'price_currency/currency_module/EUR'
,
'source/%s'
%
self
.
expected_slapos_organisation
,
'source_section/%s'
%
self
.
expected_slapos_organisation
,
'specialise/%s'
%
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
],
built_delivery
.
getCategoryList
())
self
.
assertEqual
(
DateTime
().
earliestTime
(),
built_delivery
.
getStartDate
())
delivery_line_list
=
built_delivery
.
contentValues
(
portal_type
=
'Sale Packing List Line'
)
self
.
assertEqual
(
1
,
len
(
delivery_line_list
))
built_delivery_line
=
delivery_line_list
[
0
]
self
.
assertEqual
(
1.0
,
built_delivery_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_delivery_line
.
getPrice
())
self
.
assertEqual
(
delivery_line
.
getResource
(),
built_delivery_line
.
getResource
())
def
test_many_lines
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery
=
self
.
_createDelivery
(
destination_value
=
person
,
destination_decision_value
=
person
)
setup_line_1
=
self
.
_addDeliveryLine
(
delivery
)
setup_line_2
=
self
.
_addDeliveryLine
(
delivery
)
cleanup_line
=
self
.
_addDeliveryLine
(
delivery
,
resource
=
'service_module/slapos_instance_cleanup'
)
update_line
=
self
.
_addDeliveryLine
(
delivery
,
resource
=
'service_module/slapos_instance_update'
)
subscription_line
=
self
.
_addDeliveryLine
(
delivery
,
resource
=
'service_module/slapos_instance_subscription'
)
self
.
tic
()
delivery_list
=
self
.
fullBuild
(
uid
=
[
setup_line_1
.
getUid
(),
setup_line_2
.
getUid
(),
cleanup_line
.
getUid
(),
update_line
.
getUid
(),
subscription_line
.
getUid
()])
self
.
assertEqual
(
1
,
len
(
delivery_list
))
built_delivery
=
delivery_list
[
0
]
self
.
assertEqual
(
setup_line_1
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
setup_line_2
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
cleanup_line
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
update_line
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
'confirmed'
,
built_delivery
.
getSimulationState
())
self
.
assertEqual
(
'building'
,
built_delivery
.
getCausalityState
())
delivery_line_list
=
built_delivery
.
contentValues
(
portal_type
=
'Sale Packing List Line'
)
self
.
assertEqual
(
4
,
len
(
delivery_line_list
))
built_setup_line
=
[
q
for
q
in
delivery_line_list
if
q
.
getResource
()
==
'service_module/slapos_instance_setup'
][
0
]
built_cleanup_line
=
[
q
for
q
in
delivery_line_list
if
q
.
getResource
()
==
'service_module/slapos_instance_cleanup'
][
0
]
built_update_line
=
[
q
for
q
in
delivery_line_list
if
q
.
getResource
()
==
'service_module/slapos_instance_update'
][
0
]
built_subscription_line
=
[
q
for
q
in
delivery_line_list
if
q
.
getResource
()
==
'service_module/slapos_instance_subscription'
][
0
]
self
.
assertEqual
(
2.0
,
built_setup_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_setup_line
.
getPrice
())
self
.
assertEqual
(
setup_line_1
.
getResource
(),
built_setup_line
.
getResource
())
self
.
assertEqual
(
1.0
,
built_cleanup_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_cleanup_line
.
getPrice
())
self
.
assertEqual
(
cleanup_line
.
getResource
(),
built_cleanup_line
.
getResource
())
self
.
assertEqual
(
1.0
,
built_update_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_update_line
.
getPrice
())
self
.
assertEqual
(
update_line
.
getResource
(),
built_update_line
.
getResource
())
self
.
assertEqual
(
1.0
,
built_subscription_line
.
getQuantity
())
self
.
assertAlmostEqual
(
0.0
,
built_subscription_line
.
getPrice
(),
3
)
self
.
assertEqual
(
subscription_line
.
getResource
(),
built_subscription_line
.
getResource
())
def
test_added_after
(
self
):
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery
=
self
.
_createDelivery
(
destination_value
=
person
,
destination_decision_value
=
person
)
delivery_line
=
self
.
_addDeliveryLine
(
delivery
)
self
.
tic
()
delivery_list
=
self
.
fullBuild
(
uid
=
delivery_line
.
getUid
())
self
.
assertEqual
(
1
,
len
(
delivery_list
))
built_delivery
=
delivery_list
[
0
]
self
.
assertEqual
(
delivery_line
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
'confirmed'
,
built_delivery
.
getSimulationState
())
self
.
assertEqual
(
'building'
,
built_delivery
.
getCausalityState
())
delivery_line_list
=
built_delivery
.
contentValues
(
portal_type
=
'Sale Packing List Line'
)
self
.
assertEqual
(
1
,
len
(
delivery_line_list
))
built_delivery_line
=
delivery_line_list
[
0
]
self
.
assertEqual
(
1.0
,
built_delivery_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_delivery_line
.
getPrice
())
self
.
assertEqual
(
delivery_line
.
getResource
(),
built_delivery_line
.
getResource
())
delivery_line_2
=
self
.
_addDeliveryLine
(
delivery
)
self
.
tic
()
delivery_list
=
self
.
fullBuild
(
uid
=
delivery_line_2
.
getUid
())
self
.
assertEqual
(
1
,
len
(
delivery_list
))
new_built_delivery
=
delivery_list
[
0
]
self
.
assertEqual
(
built_delivery
,
new_built_delivery
)
self
.
assertEqual
(
delivery_line_2
.
getGroupingReference
(),
built_delivery
.
getReference
())
self
.
assertEqual
(
'confirmed'
,
built_delivery
.
getSimulationState
())
self
.
assertEqual
(
'building'
,
built_delivery
.
getCausalityState
())
delivery_line_list
=
built_delivery
.
contentValues
(
portal_type
=
'Sale Packing List Line'
)
self
.
assertEqual
(
1
,
len
(
delivery_line_list
))
built_delivery_line
=
delivery_line_list
[
0
]
self
.
assertEqual
(
2.0
,
built_delivery_line
.
getQuantity
())
self
.
assertEqual
(
0.0
,
built_delivery_line
.
getPrice
())
self
.
assertEqual
(
delivery_line_2
.
getResource
(),
built_delivery_line
.
getResource
())
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.xml
View file @
2687799b
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSAccountingBuilder
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</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