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
7a5372ea
Commit
7a5372ea
authored
Feb 14, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: revert aggregated builder test removal
parent
2687799b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
181 additions
and
0 deletions
+181
-0
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
...ortal_components/test.erp5.testSlapOSAccountingBuilder.py
+181
-0
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
View file @
7a5372ea
...
@@ -1834,3 +1834,184 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
...
@@ -1834,3 +1834,184 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self
.
assertEqual
(
invoice_2
.
getRelativeUrl
(),
self
.
assertEqual
(
invoice_2
.
getRelativeUrl
(),
model_line_2_tax_bis
.
getParentValue
().
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
())
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