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
77779e0e
Commit
77779e0e
authored
May 10, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: test: update virtual master with/without accounting
parent
d67187fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
82 deletions
+92
-82
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
...mponents/test.erp5.testSlapOSERP5VirtualMasterScenario.py
+92
-82
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
View file @
77779e0e
...
@@ -91,7 +91,7 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
...
@@ -91,7 +91,7 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
return
instance_node
return
instance_node
def
bootstrapVirtualMasterTest
(
self
):
def
bootstrapVirtualMasterTest
(
self
,
is_virtual_master_accountable
=
True
):
self
.
web_site
=
self
.
portal
.
web_site_module
.
slapos_master_panel
self
.
web_site
=
self
.
portal
.
web_site_module
.
slapos_master_panel
# some preparation
# some preparation
preference
=
self
.
portal
.
portal_preferences
.
slapos_default_system_preference
preference
=
self
.
portal
.
portal_preferences
.
slapos_default_system_preference
...
@@ -146,19 +146,18 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
...
@@ -146,19 +146,18 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
)
seller_bank_account
=
seller_organisation
.
newContent
(
seller_bank_account
=
seller_organisation
.
newContent
(
portal_type
=
"Bank Account"
,
portal_type
=
"Bank Account"
,
title
=
"test_bank_account_%s"
%
self
.
generateNewId
()
title
=
"test_bank_account_%s"
%
self
.
generateNewId
(),
price_currency_value
=
currency
)
)
seller_bank_account
.
validate
()
seller_organisation
.
validate
()
seller_organisation
.
validate
()
#
Create Trade Condition to create Project
#
Sale Trade Condition for Tax
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
portal_type
=
"Sale Trade Condition"
,
reference
=
'seller_organisation_%s'
%
seller_organisation
.
getTitle
(),
reference
=
"Tax/payment for: %s"
%
currency
.
getRelativeUrl
(),
# XXX hardcoded
# XXX hardcoded
specialise
=
"business_process_module/slapos_ultimate_business_process"
,
specialise
=
"business_process_module/slapos_ultimate_business_process"
,
source_value
=
seller_organisation
,
source_section_value
=
seller_organisation
,
source_payment_value
=
seller_bank_account
,
price_currency_value
=
currency
,
price_currency_value
=
currency
,
payment_condition_payment_mode
=
'test-%s'
%
self
.
generateNewId
()
payment_condition_payment_mode
=
'test-%s'
%
self
.
generateNewId
()
)
)
...
@@ -175,6 +174,23 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
...
@@ -175,6 +174,23 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
)
sale_trade_condition
.
validate
()
sale_trade_condition
.
validate
()
# Create Trade Condition to create Project
if
is_virtual_master_accountable
:
source_section_value
=
seller_organisation
title
=
"Payable Virtual Master (%s)"
%
seller_organisation
.
getTitle
()
else
:
source_section_value
=
None
title
=
"Free Virtual Master (%s)"
%
seller_organisation
.
getTitle
()
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
reference
=
title
,
specialise_value
=
sale_trade_condition
,
source_value
=
seller_organisation
,
source_section_value
=
source_section_value
)
sale_trade_condition
.
validate
()
sale_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
sale_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
portal_type
=
"Sale Supply"
,
portal_type
=
"Sale Supply"
,
price_currency_value
=
currency
price_currency_value
=
currency
...
@@ -187,40 +203,19 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
...
@@ -187,40 +203,19 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
)
sale_supply
.
validate
()
sale_supply
.
validate
()
return
currency
,
seller_organisation
,
seller_bank_account
return
currency
,
seller_organisation
,
seller_bank_account
,
sale_person
def
assertRelatedObjectCount
(
self
,
document
,
count
):
related_object_list
=
document
.
Base_getRelatedObjectList
(
**
{
'category.category_strict_membership'
:
1
})
related_object_list
=
[
x
.
getRelativeUrl
()
for
x
in
related_object_list
]
related_object_list
.
sort
()
assert
len
(
related_object_list
)
==
count
,
'%i
\
n
%s'
%
(
len
(
related_object_list
),
'
\
n
'
.
join
(
related_object_list
))
class
TestSlapOSVirtualMasterScenario
(
TestSlapOSVirtualMasterScenarioMixin
):
class
TestSlapOSVirtualMasterScenario
(
TestSlapOSVirtualMasterScenarioMixin
):
def
test_virtual_master_without_accounting_scenario
(
self
):
def
test_virtual_master_without_accounting_scenario
(
self
):
currency
,
seller_organisation
,
seller_bank_account
=
self
.
bootstrapVirtualMasterTest
()
_
,
_
,
_
,
sale_person
=
self
.
bootstrapVirtualMasterTest
(
is_virtual_master_accountable
=
False
)
# Create Trade Condition to create Project
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
reference
=
'free_for_organisation_%s'
%
seller_organisation
.
getTitle
(),
# XXX hardcoded
specialise
=
"business_process_module/slapos_ultimate_business_process"
,
#destination_project_value=project,
source_value
=
seller_organisation
,
#source_section_value=seller_organisation,
source_payment_value
=
seller_bank_account
,
destination_section_value
=
seller_organisation
,
price_currency_value
=
currency
,
payment_condition_payment_mode
=
'test-%s'
%
self
.
generateNewId
()
)
sale_trade_condition
.
newContent
(
portal_type
=
"Trade Model Line"
,
reference
=
"VAT"
,
resource
=
"service_module/slapos_tax"
,
base_application
=
"base_amount/invoicing/taxable"
,
trade_phase
=
"slapos/tax"
,
price
=
0.2
,
quantity
=
1.0
,
membership_criterion_base_category
=
(
'price_currency'
,),
membership_criterion_category
=
(
'price_currency/%s'
%
currency
.
getRelativeUrl
(),)
)
sale_trade_condition
.
validate
()
self
.
tic
()
self
.
tic
()
self
.
logout
()
self
.
logout
()
...
@@ -232,17 +227,13 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -232,17 +227,13 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
owner_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
owner_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"ERP5 Login"
,
portal_type
=
"ERP5 Login"
,
reference
=
owner_reference
).
getParentValue
()
reference
=
owner_reference
).
getParentValue
()
owner_person
.
setCareerSubordinationValue
(
seller_organisation
)
#
owner_person.setCareerSubordinationValue(seller_organisation)
"""
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project)"""
self
.
tic
()
self
.
tic
()
# hooray, now it is time to create compute_nodes
# hooray, now it is time to create compute_nodes
self
.
logout
()
self
.
logout
()
self
.
login
(
owner
_person
.
getUserId
())
self
.
login
(
sale
_person
.
getUserId
())
# create a default project
# create a default project
project_relative_url
=
self
.
addProject
(
person
=
owner_person
)
project_relative_url
=
self
.
addProject
(
person
=
owner_person
)
...
@@ -259,6 +250,11 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -259,6 +250,11 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
]
]
)
)
# first slapos administrator assignment can only be created by
# the erp5 manager
self
.
addProjectProductionManagerAssignment
(
owner_person
,
project
)
self
.
tic
()
self
.
logout
()
self
.
logout
()
self
.
login
(
owner_person
.
getUserId
())
self
.
login
(
owner_person
.
getUserId
())
...
@@ -335,18 +331,26 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -335,18 +331,26 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self
.
logout
()
self
.
logout
()
self
.
stepCallAlarmList
()
for
_
in
range
(
3
):
self
.
tic
()
self
.
stepCallAlarmList
()
self
.
tic
()
self
.
login
()
self
.
login
()
# Ensure no unexpected object has been created
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 compute node, 1 software installation
# 1 software instance
# 2 credential request
# 3 allocation supply, line, cell
# 3 allocation supply, line, cell
# 1 compute node
# 1 credential request
# 1 instance tree
# 3 open sale order XXX * 2 why
# 2 assignment
# 3 simulation movement
# 3 sale packing list / line
# 2 sale trade condition ( a 3rd trade condition is not linked to the project)
# 1 software installation
# 1 software instance
# 1 software product
# 1 software product
related_object_list
=
project
.
Base_getRelatedObjectList
(
**
{
'category.category_strict_membership'
:
1
})
# 3 subscription request
assert
len
(
related_object_list
)
==
13
,
[
x
.
getRelativeUrl
()
for
x
in
related_object_list
]
self
.
assertRelatedObjectCount
(
project
,
28
)
self
.
stepcheckERP5Consistency
()
self
.
stepcheckERP5Consistency
()
...
@@ -356,7 +360,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -356,7 +360,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def
test_virtual_master_with_accounting_scenario
(
self
):
def
test_virtual_master_with_accounting_scenario
(
self
):
currency
,
_
,
_
=
self
.
bootstrapVirtualMasterTest
()
currency
,
_
,
_
,
sale_person
=
self
.
bootstrapVirtualMasterTest
()
self
.
logout
()
self
.
logout
()
# lets join as slapos administrator, which will own few compute_nodes
# lets join as slapos administrator, which will own few compute_nodes
...
@@ -377,10 +381,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -377,10 +381,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# hooray, now it is time to create compute_nodes
# hooray, now it is time to create compute_nodes
self
.
logout
()
self
.
logout
()
self
.
login
(
owner
_person
.
getUserId
())
self
.
login
(
sale
_person
.
getUserId
())
# create a default project
project_relative_url
=
self
.
addProject
(
is_accountable
=
True
,
person
=
owner_person
)
project_relative_url
=
self
.
addProject
(
person
=
owner_person
)
self
.
logout
()
self
.
logout
()
...
@@ -487,7 +490,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -487,7 +490,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self
.
logout
()
self
.
logout
()
for
_
in
range
(
2
0
):
for
_
in
range
(
2
):
self
.
stepCallAlarmList
()
self
.
stepCallAlarmList
()
self
.
tic
()
self
.
tic
()
...
@@ -518,7 +521,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -518,7 +521,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self
.
logout
()
self
.
logout
()
for
_
in
range
(
2
0
):
for
_
in
range
(
1
0
):
self
.
stepCallAlarmList
()
self
.
stepCallAlarmList
()
self
.
tic
()
self
.
tic
()
self
.
login
()
self
.
login
()
...
@@ -550,24 +553,22 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -550,24 +553,22 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self
.
login
()
self
.
login
()
# Ensure no unexpected object has been created
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 compute node, 1 software installation
# 3 accounting transaction / line
# 1 software instance
# 3 allocation supply / line / cell
# 1 compute node
# 2 credential request
# 2 credential request
# 1 instance tree
# 1 open order
# 6 open sale order / line
# 1 hosting subscription
# 3 (can reduce to 2) assignment
# 1 accounting transaction
# 16 simulation mvt
# 1 packing list
# 3 packing list / line
# 7 simulation mvt
# 4 sale supply / line
# 2 sale trade condition
# 1 software installation
# 1 software instance
# 1 software product
# 1 software product
# 1 sale trace condition
# 3 subscription requests
# 1 supply, 1 supply line
self
.
assertRelatedObjectCount
(
project
,
50
)
# 1 open order line / 1 cell
# 3 allocation supply / line / cell
related_object_list
=
project
.
Base_getRelatedObjectList
(
**
{
'category.category_strict_membership'
:
1
})
assert
len
(
related_object_list
)
==
29
,
'%s %s'
%
(
len
(
related_object_list
),
[
x
.
getRelativeUrl
()
for
x
in
related_object_list
])
self
.
stepcheckERP5Consistency
()
self
.
stepcheckERP5Consistency
()
...
@@ -577,18 +578,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -577,18 +578,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def
test_virtual_master_slave_without_accounting_scenario
(
self
):
def
test_virtual_master_slave_without_accounting_scenario
(
self
):
# create a default project
_
,
_
,
_
,
sale_person
=
self
.
bootstrapVirtualMasterTest
()
project
=
self
.
addProject
()
self
.
web_site
=
self
.
portal
.
web_site_module
.
slapos_master_panel
preference
=
self
.
portal
.
portal_preferences
.
slapos_default_system_preference
self
.
web_site
=
self
.
portal
.
web_site_module
.
slapos_master_panel
preference
.
edit
(
preferred_subscription_assignment_category_list
=
[
'function/customer'
,
'role/client'
,
'destination_project/%s'
%
project
.
getRelativeUrl
()
]
)
# some preparation
# some preparation
self
.
logout
()
self
.
logout
()
...
@@ -601,7 +593,25 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -601,7 +593,25 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
owner_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
owner_person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"ERP5 Login"
,
portal_type
=
"ERP5 Login"
,
reference
=
owner_reference
).
getParentValue
()
reference
=
owner_reference
).
getParentValue
()
self
.
tic
()
self
.
logout
()
self
.
login
(
sale_person
.
getUserId
())
# create a default project
project_relative_url
=
self
.
addProject
(
person
=
owner_person
)
self
.
logout
()
self
.
login
()
project
=
self
.
portal
.
restrictedTraverse
(
project_relative_url
)
preference
=
self
.
portal
.
portal_preferences
.
slapos_default_system_preference
preference
.
edit
(
preferred_subscription_assignment_category_list
=
[
'function/customer'
,
'role/client'
,
'destination_project/%s'
%
project
.
getRelativeUrl
()
]
)
# first slapos administrator assignment can only be created by
# first slapos administrator assignment can only be created by
# the erp5 manager
# the erp5 manager
self
.
addProjectProductionManagerAssignment
(
owner_person
,
project
)
self
.
addProjectProductionManagerAssignment
(
owner_person
,
project
)
...
...
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