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
0
Merge Requests
0
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
Titouan Soulard
slapos.core
Commits
e84c1d03
Commit
e84c1d03
authored
Mar 06, 2023
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: wip testSlapOSERP5VirtualMasterInvoicingScenario
parent
fd7d4727
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
322 additions
and
8 deletions
+322
-8
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.py
...test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.py
+201
-0
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.xml
...est.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.xml
+112
-0
master/bt5/slapos_erp5/bt/template_test_id_list
master/bt5/slapos_erp5/bt/template_test_id_list
+9
-8
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.py
0 → 100644
View file @
e84c1d03
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2022 Nexedi SA and Contributors. All Rights Reserved.
#
##############################################################################
from
erp5.component.test.testSlapOSERP5VirtualMasterScenario
import
TestSlapOSVirtualMasterScenarioMixin
# from DateTime import DateTime
class
TestSlapOSVirtualMasterInvoicingScenario
(
TestSlapOSVirtualMasterScenarioMixin
):
def
createAccountableProject
(
self
):
# create a default project
project
=
self
.
addProject
(
is_accountable
=
True
)
self
.
web_site
=
self
.
portal
.
web_site_module
.
slapos_master_panel
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
()
]
)
return
project
,
self
.
web_site
def
createProjectAdministrator
(
self
,
project
,
web_site
):
self
.
logout
()
login
=
'owner-%s'
%
self
.
generateNewId
()
self
.
joinSlapOS
(
web_site
,
login
)
self
.
login
()
person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"ERP5 Login"
,
reference
=
login
).
getParentValue
()
# first slapos administrator assignment can only be created by
# the erp5 manager
self
.
addProjectProductionManagerAssignment
(
person
,
project
)
self
.
tic
()
return
person
def
createSoftwareProduct
(
self
,
project
,
person
):
self
.
logout
()
self
.
login
(
person
.
getUserId
())
software_url
=
self
.
generateNewSoftwareReleaseUrl
()
software_type
=
'public type'
return
self
.
addSoftwareProduct
(
"instance product"
,
project
,
software_url
,
software_type
)
def
createPreparedComputeNode
(
self
,
project
,
person
,
software_product
,
release_variation
,
type_variation
):
self
.
logout
()
self
.
login
(
person
.
getUserId
())
server_title
=
'Server for %s'
%
project
.
getReference
()
server_id
=
self
.
requestComputeNode
(
server_title
,
project
.
getReference
())
server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Compute Node'
,
reference
=
server_id
)
self
.
setAccessToMemcached
(
server
)
self
.
assertNotEqual
(
None
,
server
)
self
.
setServerOpenPublic
(
server
)
self
.
addAllocationSupply
(
"for compute node"
,
server
,
software_product
,
release_variation
,
type_variation
)
# and install some software on them
self
.
supplySoftware
(
server
,
release_variation
.
getUrlString
())
# format the compute_nodes
self
.
formatComputeNode
(
server
)
return
server
def
createSoftwareProductSaleSupply
(
self
,
software_product
,
price
=
9
):
self
.
logout
()
# XXX Use accountant account
self
.
login
()
project
=
software_product
.
getFollowUpValue
()
sale_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
portal_type
=
"Sale Supply"
,
destination_project_value
=
project
,
price_currency_value
=
project
.
getSpecialiseValue
().
getPriceCurrencyValue
()
)
# XXX Put price in sale supply module
sale_supply
.
newContent
(
portal_type
=
"Sale Supply Line"
,
base_price
=
price
,
resource_value
=
software_product
)
sale_supply
.
validate
()
def
bootstrapInvoicingScenario
(
self
):
# Done by ERP5 admin?
project
,
web_site
=
self
.
createAccountableProject
()
# lets join as slapos administrator, which will own few compute_nodes
owner_person
=
self
.
createProjectAdministrator
(
project
,
web_site
)
# create a software product
software_product
,
release_variation
,
type_variation
=
self
.
createSoftwareProduct
(
project
,
owner_person
)
# create compute_nodes and prepare it
compute_node
=
self
.
createPreparedComputeNode
(
project
,
owner_person
,
software_product
,
release_variation
,
type_variation
)
# define price
self
.
createSoftwareProductSaleSupply
(
software_product
)
return
project
,
web_site
,
software_product
,
release_variation
,
type_variation
,
compute_node
def
createProjectCustomer
(
self
,
project
,
web_site
):
# join as the another visitor and request software instance on public
# compute_node
self
.
logout
()
login
=
'customer-%s'
%
self
.
generateNewId
()
self
.
joinSlapOS
(
web_site
,
login
)
self
.
login
()
person
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"ERP5 Login"
,
reference
=
login
).
getParentValue
()
return
person
,
login
def
test_virtual_master_invoice_grouped_per_user
(
self
):
project
,
web_site
,
software_product
,
release_variation
,
type_variation
,
public_server
=
self
.
bootstrapInvoicingScenario
()
public_server_software
=
release_variation
.
getUrlString
()
public_instance_type
=
type_variation
.
getTitle
()
# create a customer
public_person
,
public_reference
=
self
.
createProjectCustomer
(
project
,
web_site
)
public_instance_title
=
'Public title %s'
%
self
.
generateNewId
()
self
.
checkInstanceAllocation
(
public_person
.
getUserId
(),
public_reference
,
public_instance_title
,
public_server_software
,
public_instance_type
,
public_server
,
project
.
getReference
())
# XXX Do this for every scenario tests
self
.
logout
()
for
_
in
range
(
20
):
self
.
stepCallAlarmList
()
self
.
tic
()
self
.
tic
()
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self
.
logout
()
for
_
in
range
(
20
):
self
.
stepCallAlarmList
()
self
.
tic
()
self
.
login
()
# Check stock
inventory_list
=
self
.
portal
.
portal_simulation
.
getCurrentInventoryList
(
**
{
'group_by_section'
:
False
,
'group_by_node'
:
True
,
'group_by_variation'
:
True
,
'resource_uid'
:
software_product
.
getUid
(),
'node_uid'
:
public_person
.
getUid
(),
'project_uid'
:
project
.
getUid
(),
'ledger_uid'
:
self
.
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
})
assert
len
(
inventory_list
)
==
1
,
len
(
inventory_list
)
assert
inventory_list
[
0
].
quantity
==
1
,
inventory_list
[
0
].
quantity
resource_vcl
=
[
'software_release/%s'
%
release_variation
.
getRelativeUrl
(),
'software_type/%s'
%
type_variation
.
getRelativeUrl
()
]
resource_vcl
.
sort
()
assert
inventory_list
[
0
].
getVariationCategoryList
()
==
resource_vcl
,
"%s %s"
%
(
resource_vcl
,
inventory_list
[
0
].
getVariationCategoryList
())
# Check accounting
transaction_list
=
self
.
portal
.
account_module
.
receivable
.
Account_getAccountingTransactionList
(
mirror_section_uid
=
public_person
.
getUid
())
assert
len
(
transaction_list
)
==
1
,
len
(
transaction_list
)
assert
transaction_list
[
0
].
total_price
==
10.8
,
transaction_list
[
0
].
total_price
self
.
login
()
# 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
# 1 open order
# 1 hosting subscription
# 1 accounting transaction
# 1 packing list
# 7 simulation mvt
# 1 software product
# 1 sale trace condition
# 1 supply, 1 supply line
# 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
()
# after accept, an email is send containing the reset link
last_message
=
self
.
portal
.
MailHost
.
_last_message
assert
last_message
is
None
,
last_message
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario.xml
0 → 100644
View file @
e84c1d03
<?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>
testSlapOSERP5VirtualMasterInvoicingScenario
</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.testSlapOSERP5VirtualMasterInvoicingScenario
</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_erp5/bt/template_test_id_list
View file @
e84c1d03
test.erp5.testSlapOSAuthenticationPolicy
test.erp5.testSlapOSCodingStyle
test.erp5.testSlapOSERP5Alarm
test.erp5.testSlapOSERP5DefaultScenario
test.erp5.testSlapOSERP5GroupRoleSecurity
test.erp5.testSlapOSERP5InteractionWorkflow
test.erp5.testSlapOSERP5LocalPermissionSlapOSInteractionWorkflow
test.erp5.testSlapOSERP5SiteDump
test.erp5.testSlapOSERP5GroupRoleSecurity
test.erp5.testSlapOSERP5SkinSelection
test.erp5.testSlapOSERP5DefaultScenario
test.erp5.testSlapOSXHTML
test.erp5.testSlapOSCodingStyle
test.erp5.testSlapOSAuthenticationPolicy
test.erp5.testSlapOSERP5InteractionWorkflow
test.erp5.testSlapOSWendelinCoreTwo
test.erp5.testSlapOSPrecacheManifest
test.erp5.testSlapOSERP5VirtualMasterInvoicingScenario
test.erp5.testSlapOSERP5VirtualMasterScenario
test.erp5.testSlapOSPrecacheManifest
test.erp5.testSlapOSWendelinCoreTwo
test.erp5.testSlapOSXHTML
\ 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