Commit f4c6f74a authored by Romain Courteaud's avatar Romain Courteaud

slapos_panel_ui_test: use Person_addVirtualMaster

parent 3de9bcbd
......@@ -20,41 +20,61 @@ def ERP5Site_activateAlarmSlapOSPanelTest(self):
return "Alarms activated."
def ERP5Site_bootstrapSlapOSPanelTest(self, scenario, customer_login,
def ERP5Site_bootstrapSlapOSPanelTest(self, step, scenario, customer_login,
manager_login, remote_customer_login,
passwd):
if step not in ['trade_condition', 'account']:
raise ValueError('Unsupported bootstrap step: %s' % step)
if scenario not in ['accounting', 'customer', 'customer_shared',
'customer_remote']:
raise ValueError('Unsupported bootstrap scenario: %s' % scenario)
portal = self.getPortalObject()
if step == 'trade_condition':
#################################################
# Bootstrap users
#################################################
sm = getSecurityManager()
try:
newSecurityManager(None, portal.acl_users.getUser(SUPER_USER))
self.testromain()
if scenario == 'accounting':
# Organisation
organisation = portal.organisation_module.newContent(
portal_type="Organisation",
title="Test accounting organisation"
)
else:
organisation = None
# Create Project
project = portal.project_module.newContent(
portal_type="Project",
title='Test Project',
destination_section_value=organisation
# Currency
currency = portal.currency_module.newContent(
portal_type="Currency",
title="Test currency"
)
project.validate()
if scenario == 'customer_remote':
remote_project = portal.project_module.newContent(
portal_type="Project",
title='Test Remote Project'
# Sale trade condition
trade_condition = portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
title="Test currency",
price_currency_value=currency,
source_value=organisation,
#source_section_value=organisation,
source_section_value=organisation if (scenario == 'accounting') else None,
specialise='business_process_module/slapos_ultimate_business_process',
)
remote_project.validate()
trade_condition.validate()
finally:
setSecurityManager(sm)
elif step == 'account':
sm = getSecurityManager()
try:
newSecurityManager(None, portal.acl_users.getUser(SUPER_USER))
# Fake user registrations
# Bootstrap one manager user
manager_person = portal.person_module.newContent(
......@@ -62,21 +82,6 @@ def ERP5Site_bootstrapSlapOSPanelTest(self, scenario, customer_login,
first_name='Manual test Project Manager',
default_email_coordinate_text='romain+manager@nexedi.com'
)
manager_person.newContent(
portal_type='Assignment',
title='Production Manager for project %s' % project.getTitle(),
destination_project_value=project,
function='production/manager'
).open()
if scenario == 'customer_shared':
# XXX For shared instance, user must also be a customer
# How to create Instance Node without any user related document?
manager_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % project.getTitle(),
destination_project_value=project,
function='customer'
).open()
manager_person.newContent(
portal_type='ERP5 Login',
reference=manager_login,
......@@ -90,12 +95,6 @@ def ERP5Site_bootstrapSlapOSPanelTest(self, scenario, customer_login,
first_name='Manual test Project Customer',
default_email_coordinate_text='romain+customer@nexedi.com'
)
customer_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % project.getTitle(),
destination_project_value=project,
function='customer'
).open()
customer_person.newContent(
portal_type='ERP5 Login',
reference=customer_login,
......@@ -104,25 +103,12 @@ def ERP5Site_bootstrapSlapOSPanelTest(self, scenario, customer_login,
customer_person.validate()
if scenario == 'customer_remote':
customer_person.newContent(
portal_type='Assignment',
title='Production Manager for project %s' % remote_project.getTitle(),
destination_project_value=remote_project,
function='production/manager'
).open()
# Bootstrap one customer user for the remote project
remote_customer_person = portal.person_module.newContent(
portal_type='Person',
first_name='Manual test Remote Project Customer',
default_email_coordinate_text='romain+remote+customer@nexedi.com'
)
remote_customer_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % remote_project.getTitle(),
destination_project_value=remote_project,
function='customer'
).open()
remote_customer_person.newContent(
portal_type='ERP5 Login',
reference=remote_customer_login,
......@@ -130,6 +116,63 @@ def ERP5Site_bootstrapSlapOSPanelTest(self, scenario, customer_login,
).validate()
remote_customer_person.validate()
currency = portal.portal_catalog.getResultValue(
portal_type="Currency",
title="Test currency",
sort_on=[['creation_date', 'DESC']]
)
# Create Project
project = manager_person.Person_addVirtualMaster(
'Test Project',
scenario == 'accounting',
scenario == 'accounting',
currency.getRelativeUrl(),
batch=1)
manager_person.newContent(
portal_type='Assignment',
title='Manager for project %s' % project.getTitle(),
destination_project_value=project,
function='production/manager'
).open()
customer_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % project.getTitle(),
destination_project_value=project,
function='customer'
).open()
if scenario == 'customer_shared':
# XXX For shared instance, user must also be a customer
# How to create Instance Node without any user related document?
manager_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % project.getTitle(),
destination_project_value=project,
function='customer'
).open()
if scenario == 'customer_remote':
remote_project = customer_person.Person_addVirtualMaster(
'Test Remote Project',
scenario == 'accounting',
scenario == 'accounting',
currency.getRelativeUrl(),
batch=1)
customer_person.newContent(
portal_type='Assignment',
title='Manager for project %s' % project.getTitle(),
destination_project_value=project,
function='production/manager'
).open()
remote_customer_person.newContent(
portal_type='Assignment',
title='Customer for project %s' % remote_project.getTitle(),
destination_project_value=remote_project,
function='customer'
).open()
finally:
setSecurityManager(sm)
......
......@@ -11,9 +11,13 @@
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -11,7 +11,19 @@
<tr>
<td>open</td>
<td tal:content="python: '${base_url}/ERP5Site_bootstrapSlapOSPanelTest?scenario=%s&manager_login=%s&customer_login=%s&remote_customer_login=%s&passwd=%s' % (init_configuration['scenario'], user_configuration['manager_login'], user_configuration['customer_login'], user_configuration['remote_customer_login'], user_configuration['passwd'])">.../ERP5Site_bootstrapSlapOSPanelTest</td>
<td tal:content="python: '${base_url}/ERP5Site_bootstrapSlapOSPanelTest?step=trade_condition&scenario=%s&manager_login=%s&customer_login=%s&remote_customer_login=%s&passwd=%s' % (init_configuration['scenario'], user_configuration['manager_login'], user_configuration['customer_login'], user_configuration['remote_customer_login'], user_configuration['passwd'])">.../ERP5Site_bootstrapSlapOSPanelTest</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Done.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr>
<td>open</td>
<td tal:content="python: '${base_url}/ERP5Site_bootstrapSlapOSPanelTest?step=account&scenario=%s&manager_login=%s&customer_login=%s&remote_customer_login=%s&passwd=%s' % (init_configuration['scenario'], user_configuration['manager_login'], user_configuration['customer_login'], user_configuration['remote_customer_login'], user_configuration['passwd'])">.../ERP5Site_bootstrapSlapOSPanelTest</td>
<td></td>
</tr>
<tr>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment