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
9d9a3f49
Commit
9d9a3f49
authored
Nov 09, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: wip sale supply test
parent
93c5a89d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
272 additions
and
0 deletions
+272
-0
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py
...eItem/portal_components/test.erp5.testSlapOSSaleSupply.py
+159
-0
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.xml
...Item/portal_components/test.erp5.testSlapOSSaleSupply.xml
+112
-0
master/bt5/slapos_accounting/bt/template_test_id_list
master/bt5/slapos_accounting/bt/template_test_id_list
+1
-0
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py
0 → 100644
View file @
9d9a3f49
# Copyright (c) 2022 Nexedi SA and Contributors. All Rights Reserved.
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
DateTime
import
DateTime
from
Products.CMFCore.utils
import
getToolByName
class
TestSlapOSSaleSupply
(
SlapOSTestCaseMixin
):
def
test_check
(
self
):
# Create 2 projects
project_1
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
"Project"
,
title
=
"project_1"
)
project_2
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
"Project"
,
title
=
"project_2"
)
# Create 2 software product
# - one with 1 release and 1 type
# - one with 2 releases and 2 types
simple_product
=
self
.
portal
.
software_product_module
.
newContent
(
portal_type
=
"Software Product"
,
title
=
"Simple Product"
)
simple_product
.
newContent
(
portal_type
=
"Software Product Type Variation"
,
title
=
"software_type_a"
)
simple_product
.
newContent
(
portal_type
=
"Software Product Release Variation"
,
url_string
=
"http://example.org/release_1"
)
complex_product
=
self
.
portal
.
software_product_module
.
newContent
(
portal_type
=
"Software Product"
,
title
=
"Complex Product"
)
complex_product
.
newContent
(
portal_type
=
"Software Product Type Variation"
,
title
=
"software_type_b"
)
complex_product
.
newContent
(
portal_type
=
"Software Product Type Variation"
,
title
=
"software_type_c"
)
complex_product
.
newContent
(
portal_type
=
"Software Product Release Variation"
,
url_string
=
"http://example.org/release_2"
)
complex_product
.
newContent
(
portal_type
=
"Software Product Release Variation"
,
url_string
=
"http://example.org/release_3"
)
# create 2 users
person_1
=
self
.
portal
.
person_module
.
newContent
()
person_2
=
self
.
portal
.
person_module
.
newContent
()
# Create 2 sale supplies
# - one for everybody (no destination)
# - one for one specific user
now
=
DateTime
()
everybody_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
title
=
"Everybody Supply"
,
start_date_range_min
=
now
,
destination_project_value
=
project_1
)
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
)
# Create sale Line/Cell for all product combination
sale_supply_cell_list
=
[]
base_id
=
'path'
for
sale_supply
in
[
everybody_supply
,
person_1_supply
]:
for
software_product
in
[
simple_product
,
complex_product
]:
sale_supply_line
=
sale_supply
.
newContent
(
portal_type
=
"Sale Supply Line"
,
resource_value
=
software_product
)
sale_supply_line
.
edit
(
p_variation_base_category_list
=
sale_supply_line
.
getVariationRangeBaseCategoryList
()
)
sale_supply_line
.
setCellRange
(
base_id
=
base_id
,
*
sale_supply_line
.
SupplyLine_asCellRange
(
base_id
=
base_id
)
)
for
cell_key
in
list
(
sale_supply_line
.
getCellKeyList
(
base_id
=
base_id
)):
sale_supply_cell
=
sale_supply_line
.
newCell
(
base_id
=
base_id
,
portal_type
=
'Sale Supply Cell'
,
*
cell_key
)
sale_supply_cell
.
edit
(
mapped_value_property_list
=
[
'allocable'
],
allocable
=
True
,
predicate_category_list
=
cell_key
,
variation_category_list
=
cell_key
)
sale_supply_cell_list
.
append
(
sale_supply_cell
)
sale_supply
.
validate
()
self
.
tic
()
# Create 2 movements
# one for everybody
# one for one specific user
# check if predicates match
i
=
0
domain_tool
=
getToolByName
(
self
.
portal
,
'portal_domains'
)
for
software_product
in
[
simple_product
,
complex_product
]:
for
software_type
in
software_product
.
contentValues
(
portal_type
=
"Software Product Type Variation"
):
for
software_release
in
software_product
.
contentValues
(
portal_type
=
"Software Product Release Variation"
):
for
project
in
[
project_1
,
project_2
,
None
]:
for
destination
in
[
person_1
,
person_2
,
None
]:
for
start_date
in
[
now
,
now
-
1
,
None
]:
tmp_context
=
self
.
portal
.
portal_trash
.
newContent
(
portal_type
=
'Movement'
,
temp_object
=
1
,
resource_value
=
software_product
,
software_type_value
=
software_type
,
software_release_value
=
software_release
,
start_date
=
start_date
,
destination_project_value
=
project
,
destination_value
=
destination
)
for
sale_supply_cell
in
sale_supply_cell_list
:
expected_test_result
=
(
(
software_product
.
getRelativeUrl
()
==
sale_supply_cell
.
getResource
())
and
(
software_type
.
getRelativeUrl
()
==
sale_supply_cell
.
getSoftwareType
())
and
(
software_release
.
getRelativeUrl
()
==
sale_supply_cell
.
getSoftwareRelease
())
and
(
project
==
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestinationProjectValue
())
and
((
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestinationValue
()
is
None
)
or
(
destination
==
sale_supply_cell
.
getParentValue
().
getParentValue
().
getDestinationValue
()))
and
(
start_date
==
sale_supply_cell
.
getParentValue
().
getParentValue
().
getStartDateRangeMin
())
)
assert
sale_supply_cell
.
test
(
tmp_context
)
==
expected_test_result
,
"""Expected: %s %i
Product: %s %s
Type: %s %s
Release: %s %s
Project: %s %s
Destination: %s %s
Date: %s %s
"""
%
(
expected_test_result
,
i
,
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
(),
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
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.xml
0 → 100644
View file @
9d9a3f49
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSSaleSupply
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testSlapOSSaleSupply
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</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>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/bt/template_test_id_list
View file @
9d9a3f49
test.erp5.testSlapOSConsumptionSkins
test.erp5.testSlapOSSaleSupply
test.erp5.testSlapOSAccountingConstraint
test.erp5.testSlapOSAccountingRule
test.erp5.testSlapOSAccountingBuilder
...
...
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