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
fc18ba29
Commit
fc18ba29
authored
Nov 10, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: test Supply Line matching and getPrice
parent
75caeccd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
132 additions
and
8 deletions
+132
-8
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py
...eItem/portal_components/test.erp5.testSlapOSSaleSupply.py
+132
-8
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py
View file @
fc18ba29
...
...
@@ -61,28 +61,67 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin):
# - one for everybody (no destination)
# - one for one specific user
now
=
DateTime
()
wrong_currency_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
title
=
"Wrong currency Supply"
,
start_date_range_min
=
now
,
destination_project_value
=
project_1
,
price_currency
=
"currency_module/CNY"
,
)
everybody_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
title
=
"Everybody Supply"
,
start_date_range_min
=
now
,
destination_project_value
=
project_1
destination_project_value
=
project_1
,
price_currency
=
"currency_module/EUR"
,
)
person_1_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
title
=
"Person 1 Supply"
,
start_date_range_min
=
now
,
destination_project_value
=
project_1
,
destination_value
=
person_1
destination_value
=
person_1
,
price_currency
=
"currency_module/EUR"
)
# Create sale Line/Cell for all product combination
sale_supply_cell_list
=
[]
sale_supply_line_list
=
[]
base_id
=
'path'
for
sale_supply
in
[
everybody_supply
,
person_1_supply
]:
base_price
=
0
for
sale_supply
in
[
wrong_currency_supply
,
everybody_supply
,
person_1_supply
]:
base_price
+=
1
sale_supply_line
=
sale_supply
.
newContent
(
title
=
"without resource"
,
portal_type
=
"Sale Supply Line"
,
base_price
=
base_price
,
)
sale_supply_line_list
.
append
(
sale_supply_line
)
for
software_product
in
[
simple_product
,
complex_product
]:
sale_supply_line
=
sale_supply
.
newContent
(
title
=
"%s without price"
%
software_product
.
getTitle
(),
portal_type
=
"Sale Supply Line"
,
resource_value
=
software_product
,
)
sale_supply_line_list
.
append
(
sale_supply_line
)
base_price
+=
1
sale_supply_line
=
sale_supply
.
newContent
(
title
=
"%s without variation"
%
software_product
.
getTitle
(),
portal_type
=
"Sale Supply Line"
,
resource_value
=
software_product
,
base_price
=
base_price
,
)
sale_supply_line_list
.
append
(
sale_supply_line
)
sale_supply_line
=
sale_supply
.
newContent
(
title
=
"%s with variation"
%
software_product
.
getTitle
(),
portal_type
=
"Sale Supply Line"
,
resource_value
=
software_product
)
sale_supply_line_list
.
append
(
sale_supply_line
)
base_price
+=
1
sale_supply_line
.
edit
(
base_price
=
base_price
,
p_variation_base_category_list
=
sale_supply_line
.
getVariationRangeBaseCategoryList
()
)
sale_supply_line
.
setCellRange
(
...
...
@@ -95,9 +134,10 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin):
portal_type
=
'Sale Supply Cell'
,
*
cell_key
)
base_price
+=
1
sale_supply_cell
.
edit
(
mapped_value_property_list
=
[
'
allocabl
e'
],
allocable
=
Tru
e
,
mapped_value_property_list
=
[
'
base_pric
e'
],
base_price
=
base_pric
e
,
predicate_category_list
=
cell_key
,
variation_category_list
=
cell_key
)
...
...
@@ -105,7 +145,7 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin):
sale_supply
.
validate
()
self
.
tic
()
# Create
2
movements
# Create movements
# one for everybody
# one for one specific user
# check if predicates match
...
...
@@ -126,10 +166,41 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin):
software_release_value
=
software_release
,
start_date
=
start_date
,
destination_project_value
=
project
,
destination_value
=
destination
destination_value
=
destination
,
price_currency
=
"currency_module/EUR"
)
# Check Sale Supply Cell predicate configuration
for
sale_supply_line
in
sale_supply_line_list
:
expected_test_result
=
(
(
sale_supply_line
.
hasBasePrice
())
and
(
sale_supply_line
.
getPriceCurrency
()
==
"currency_module/EUR"
)
and
(
software_product
.
getRelativeUrl
()
==
sale_supply_line
.
getResource
())
and
(
project
==
sale_supply_line
.
getParentValue
().
getDestinationProjectValue
())
and
((
sale_supply_line
.
getParentValue
().
getDestinationValue
()
is
None
)
or
(
destination
==
sale_supply_line
.
getParentValue
().
getDestinationValue
()))
and
(
start_date
==
sale_supply_line
.
getParentValue
().
getStartDateRangeMin
())
)
assert
sale_supply_line
.
test
(
tmp_context
)
==
expected_test_result
,
"""Expected: %s %i %s
Product: %s %s
Project: %s %s
Destination: %s %s
Date: %s %s
"""
%
(
expected_test_result
,
i
,
sale_supply_line
.
getRelativeUrl
(),
software_product
.
getRelativeUrl
(),
sale_supply_line
.
getResource
(),
project
.
getRelativeUrl
(),
sale_supply_line
.
getParentValue
().
getDestinationProject
(),
destination
,
sale_supply_line
.
getParentValue
().
getDestination
(),
start_date
,
sale_supply_line
.
getParentValue
().
getStartDateRangeMin
()
)
assert
(
sale_supply_line
in
domain_tool
.
searchPredicateList
(
tmp_context
,
portal_type
=
[
'Sale Supply Line'
]))
==
expected_test_result
# Check Sale Supply Cell predicate configuration
for
sale_supply_cell
in
sale_supply_cell_list
:
expected_test_result
=
(
(
sale_supply_cell
.
hasBasePrice
())
and
(
sale_supply_cell
.
getPriceCurrency
()
==
"currency_module/EUR"
)
and
(
software_product
.
getRelativeUrl
()
==
sale_supply_cell
.
getResource
())
and
(
software_type
.
getRelativeUrl
()
==
sale_supply_cell
.
getSoftwareType
())
and
(
software_release
.
getRelativeUrl
()
==
sale_supply_cell
.
getSoftwareRelease
())
and
...
...
@@ -150,10 +221,63 @@ Date: %s %s
software_product
.
getRelativeUrl
(),
sale_supply_cell
.
getResource
(),
software_type
.
getRelativeUrl
(),
sale_supply_cell
.
getSoftwareType
(),
software_release
.
getRelativeUrl
(),
sale_supply_cell
.
getSoftwareRelease
(),
project
.
getRelativeUrl
(),
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestinationProject
(),
project
.
getRelativeUrl
(),
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestinationProject
(),
destination
,
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestination
(),
start_date
,
sale_supply_cell
.
getParentValue
().
getParentValue
().
getStartDateRangeMin
()
)
assert
(
sale_supply_cell
in
domain_tool
.
searchPredicateList
(
tmp_context
,
portal_type
=
[
'Sale Supply Cell'
]))
==
expected_test_result
i
+=
1
# New variation, to check the price when not Sale Supply Cell matching
with_price_software_release
=
simple_product
.
contentValues
(
portal_type
=
"Software Product Release Variation"
)[
0
]
without_price_software_release
=
simple_product
.
newContent
(
portal_type
=
"Software Product Release Variation"
,
url_string
=
"http://example.org/release_XX"
)
software_type
=
simple_product
.
contentValues
(
portal_type
=
"Software Product Type Variation"
)[
0
]
# Create movements
# check getPrice
for
destination
,
project
,
software_release
,
date
,
expected_price
in
[
(
person_1
,
project_1
,
with_price_software_release
,
now
,
24
),
(
person_1
,
project_1
,
without_price_software_release
,
now
,
22
),
(
person_2
,
project_1
,
with_price_software_release
,
now
,
14
),
(
person_2
,
project_1
,
without_price_software_release
,
now
,
12
),
(
person_1
,
project_1
,
with_price_software_release
,
now
-
1
,
None
),
(
person_1
,
project_2
,
without_price_software_release
,
now
,
None
),
]:
resource_vcl
=
[
'software_release/%s'
%
software_release
.
getRelativeUrl
(),
'software_type/%s'
%
software_type
.
getRelativeUrl
()
]
resource_vcl
.
sort
()
tmp_context
=
self
.
portal
.
portal_trash
.
newContent
(
portal_type
=
'Sale Order Line'
,
temp_object
=
1
,
resource_value
=
simple_product
,
variation_category_list
=
resource_vcl
,
start_date
=
date
,
destination_project_value
=
project
,
destination_value
=
destination
,
quantity_unit
=
software_product
.
getQuantityUnit
(),
price_currency
=
"currency_module/EUR"
)
tmp_context
=
tmp_context
.
newContent
(
portal_type
=
'Sale Order Cell'
,
temp_object
=
1
,
software_type_value
=
software_type
,
software_release_value
=
software_release
)
#"""
# Check that price is the predicate base price
assert
tmp_context
.
getPrice
()
==
expected_price
,
"""Expected:
Price: %s %s
Destination: %s
Project: %s
Software_release: %s
Date: %s
"""
%
(
tmp_context
.
getPrice
(),
expected_price
,
destination
,
project
,
software_release
,
date
)
\ 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