Commit a39455a3 authored by Romain Courteaud's avatar Romain Courteaud

Drop deprecated code.

parent 5f10102a
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
vifib_agent
\ No newline at end of file
999
\ No newline at end of file
2011/06/15 Gabriel Monnerat
* Start Implementation of Slave Instances
2010/06/23 Lukasz Nowak
* initial release
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
529
\ No newline at end of file
vifib_base
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
39
\ No newline at end of file
vifib_core
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
16
\ No newline at end of file
vifib_crm
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
116
\ No newline at end of file
vifib_data
\ No newline at end of file
999
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_data_category
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_data_payzen
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_data_simulation
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
vifib_data_web
\ No newline at end of file
999
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
599
\ No newline at end of file
vifib_erp5
\ No newline at end of file
999
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_external_account
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_forge_release
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_invoicing
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
vifib_l10n_fr
\ No newline at end of file
999
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_mysql_innodb_catalog
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_open_trade
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
83
\ No newline at end of file
vifib_payzen
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
895
\ No newline at end of file
vifib_slap
\ No newline at end of file
999
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_accounting
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_capacity
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_core
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_rest_api
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_rest_api_tool_portal_type
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_slapos_rest_api_v1
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_software_pdm
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
384
\ No newline at end of file
vifib_test
\ No newline at end of file
999
\ No newline at end of file
2011 © Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
vifib_upgrader
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
GPL
\ No newline at end of file
497
\ No newline at end of file
vifib_web
\ No newline at end of file
999
\ No newline at end of file
Nexedi SA 2011
\ No newline at end of file
Empty placeholder for ease of "uninstallation".
\ No newline at end of file
vifib_web_ui_test
\ No newline at end of file
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager, \
getSecurityManager, setSecurityManager
from Products.ERP5Type.tests.utils import DummyMailHost
import os
from Products.ERP5Type.Utils import convertToUpperCase
class testVifibMixin(ERP5TypeTestCase):
"""
Mixin class for unit test of Vifib.
"""
run_all_test = 1
def getBusinessTemplateList(self):
"""
Install the business templates.
"""
result = [
'erp5_core_proxy_field_legacy',
'erp5_full_text_myisam_catalog',
'erp5_ingestion_mysql_innodb_catalog',
'erp5_base',
'erp5_jquery',
'erp5_ingestion',
'erp5_web',
'erp5_simulation',
'erp5_pdm',
'erp5_dms',
'erp5_crm',
'erp5_content_translation',
'erp5_trade',
'erp5_accounting',
'erp5_jquery_ui',
'erp5_xhtml_jquery_style',
'erp5_software_pdm',
'erp5_computer_immobilisation',
'erp5_item',
'erp5_invoicing',
'erp5_secure_payment',
'erp5_knowledge_pad',
'erp5_credential',
'erp5_tax_resource',
'erp5_web_download_theme',
'slapos_cloud',
'erp5_open_trade',
'erp5_tiosafe_core',
'erp5_system_event',
'erp5_simplified_invoicing',
'erp5_rss_style',
'erp5_project',
'erp5_payzen_secure_payment',
'erp5_ooo_import',
'erp5_odt_style',
'erp5_ods_style',
'erp5_l10n_fr',
'erp5_km',
'erp5_forge',
'erp5_discount_resource',
'erp5_dhtml_style',
'erp5_credential_oauth2',
'erp5_commerce',
'erp5_bearer_token',
'erp5_administration',
'erp5_accounting_l10n_fr',
'erp5_web_shacache',
'erp5_data_set',
'slapos_accounting',
'vifib_base',
'erp5_workflow',
'erp5_web_shadir',
'vifib_slap',
'slapos_rest_api_tool_portal_type',
'erp5_configurator',
'slapos_cache',
'slapos_slap_tool',
'slapos_category',
'slapos_payzen',
'slapos_pdm',
'erp5_upgrader',
'slapos_rest_api',
'vifib_data',
'slapos_configurator',
'erp5_ui_test_core',
'slapos_erp5',
'slapos_web',
'vifib_upgrader',
'vifib_slapos_accounting',
'vifib_configurator',
'erp5_ui_test',
# All business templates above are the dependency
# tree of vifib_erp5, so if you mofify this list
# make sure you also update dependency of bt.
# You can use portal_templates.resolveBusinessTemplateListDependency(["vifib_erp5"])
# in order to check this list.
'vifib_erp5',
'vifib_test',
'vifib_web_ui_test',
]
return result
def getUserFolder(self):
"""
Return the user folder
"""
return getattr(self.getPortal(), 'acl_users', None)
def loginDefaultUser(self, quiet=0):
"""
Most of the time, we need to login before doing anything
"""
uf = self.getUserFolder()
uf._doAddUser('default_user', 'default_user',
['Assignee', 'Assignor',
'Associate', 'Auditor', 'Author',
], [])
user = uf.getUserById('default_user').__of__(uf)
newSecurityManager(None, user)
def isLiveTest(self):
return 'ERP5TypeLiveTestCase' in [q.__name__ for q in self.__class__.mro()]
def setupPayZenInterface(self):
payzen = self.portal.portal_secure_payments.vifib_payzen
# avoid resetting prepared site
if payzen.getServiceUsername() is None:
payzen.setServiceUsername('12345')
if payzen.getServicePassword() == '':
payzen.setServicePassword('09876')
def setupPortalAlarms(self):
if not self.portal.portal_alarms.isSubscribed():
self.portal.portal_alarms.subscribe()
self.assertTrue(self.portal.portal_alarms.isSubscribed())
def setupPortalCertificateAuthority(self):
"""Sets up portal_certificate_authority"""
if not self.portal.hasObject('portal_certificate_authority'):
self.portal.manage_addProduct['ERP5'].manage_addTool(
'ERP5 Certificate Authority Tool', None)
self.portal.portal_certificate_authority.certificate_authority_path = \
os.environ['TEST_CA_PATH']
transaction.commit()
# reset test CA to have it always count from 0
open(os.path.join(os.environ['TEST_CA_PATH'], 'serial'), 'w').write('01')
open(os.path.join(os.environ['TEST_CA_PATH'], 'crlnumber'), 'w').write(
'01')
open(os.path.join(os.environ['TEST_CA_PATH'], 'index.txt'), 'w').write('')
def createAlarmStep(self):
def makeCallAlarm(alarm):
def callAlarm(*args, **kwargs):
sm = getSecurityManager()
self.login()
try:
alarm.activeSense(params=kwargs)
transaction.commit()
finally:
setSecurityManager(sm)
return callAlarm
for alarm in self.portal.portal_alarms.contentValues():
if alarm.isEnabled():
setattr(self, 'stepCall' + convertToUpperCase(alarm.getId()) \
+ 'Alarm', makeCallAlarm(alarm))
def setUpMemcached(self):
from Products.ERP5Type.tests.ERP5TypeTestCase import\
_getVolatileMemcachedServerDict, _getPersistentMemcachedServerDict
memcached_tool = self.getPortal().portal_memcached
# setup default volatile distributed memcached
connection_dict = _getVolatileMemcachedServerDict()
url_string = '%(hostname)s:%(port)s' % connection_dict
memcached_tool.default_memcached_plugin.setUrlString(url_string)
# setup default persistent distributed memcached
connection_dict = _getPersistentMemcachedServerDict()
url_string = '%(hostname)s:%(port)s' % connection_dict
memcached_tool.persistent_memcached_plugin.setUrlString(url_string)
def afterSetUp(self, quiet=1, run=run_all_test):
"""
Create ERP5 user.
This has to be called only once.
"""
# setup new active process for this test, in order have
# consistency report local for one test
sm = getSecurityManager()
self.login()
try:
self.portal.portal_alarms.vifib_check_consistency.newActiveProcess()
finally:
setSecurityManager(sm)
import random
self.portal.portal_caches.erp5_site_global_id = '%s' % random.random()
self.portal.portal_caches._p_changed = 1
transaction.commit()
self.portal.portal_caches.updateCache()
self.createAlarmStep()
if getattr(self.portal, 'set_up_once_called', 0):
return
else:
self.portal.set_up_once_called = 1
self.bootstrapSite()
self.portal._p_changed = 1
transaction.commit()
self.stabiliseAccounting()
def stabiliseAccounting(self):
self.stepCallSlaposUpdateDeliveryCausalityStateAlarm()
self.tic()
self.stepCallVifibSolveAutomaticallyAlarm()
self.tic()
self.stepCallVifibExpandDeliveryLineAlarm()
self.tic()
self.stepCallSlaposTriggerBuildAlarm()
self.tic()
self.stepCallSlaposUpdateDeliveryCausalityStateAlarm()
self.tic()
self.stepCallVifibSolveAutomaticallyAlarm()
self.tic()
self.stepCallVifibExpandDeliveryLineAlarm()
self.tic()
self.stepCallSlaposTriggerBuildAlarm()
self.tic()
self.stepCallSlaposUpdateDeliveryCausalityStateAlarm()
self.tic()
self.stepCallVifibSolveAutomaticallyAlarm()
self.tic()
self.stepCallStopConfirmedSaleInvoiceTransactionAlarm()
self.tic()
self.stepCallVifibExpandDeliveryLineAlarm()
self.tic()
self.stepCallSlaposTriggerBuildAlarm()
self.tic()
self.stepCallSlaposUpdateDeliveryCausalityStateAlarm()
self.tic()
self.stepCallVifibSolveAutomaticallyAlarm()
self.tic()
def getDefaultSitePreferenceId(self):
"""Default id, usefull method to override
"""
return "slapos_default_system_preference"
def prepareTestUsers(self):
"""
Prepare test users.
"""
isTransitionPossible = self.portal.portal_workflow.isTransitionPossible
for person in self.portal.portal_catalog(
portal_type="Person",
id="test_%",
):
person = person.getObject()
if isTransitionPossible(person, 'validate'):
person.validate()
for assignment in person.contentValues(portal_type='Assignment'):
if isTransitionPossible(assignment, 'open'):
assignment.open()
def markManualCreation(self, document):
self.portal.portal_workflow.doActionFor(document, 'edit_action',
comment='Manually created by test.')
def bootstrapSite(self):
"""
Manager has to create an administrator user first.
"""
if self.isLiveTest():
# nothing to do in Live Test
return
self.setupPortalAlarms()
self.setupPortalCertificateAuthority()
self.setupPayZenInterface()
self.setUpMemcached()
portal = self.getPortal()
if 'MailHost' in portal.objectIds():
portal.manage_delObjects(['MailHost'])
portal._setObject('MailHost', DummyMailHost('MailHost'))
portal.email_from_address = 'romain@nexedi.com'
portal.email_to_address = 'romain@nexedi.com'
self.clearCache()
self.logMessage("Bootstrap Vifib Without Security...")
self.login()
# Invoke Post-configurator script, this invokes all
# alarms related to configuration.
self.portal.BusinessConfiguration_invokePromiseAlarmList()
self.prepareTestUsers()
transaction.commit()
self.tic()
self.logout()
self.loginDefaultUser()
def clearCache(self):
self.portal.portal_caches.clearAllCache()
self.portal.portal_workflow.refreshWorklistCache()
# access related steps
def stepLoginDefaultUser(self, **kw):
self.login('default_user')
def stepLoginTestHrAdmin(self, **kw):
self.login('test_hr_admin')
def stepLoginTestUpdatedVifibUser(self, **kw):
self.login('test_updated_vifib_user')
def stepLoginTestVifibAdmin(self, **kw):
self.login('test_vifib_admin')
def stepLoginTestVifibCustomer(self, **kw):
self.login('test_vifib_customer')
def stepLoginTestVifibCustomerA(self, **kw):
self.login('test_vifib_customer_a')
def stepLoginTestVifibDeveloper(self, **kw):
self.login('test_vifib_developer')
def stepLoginTestVifibMember(self, **kw):
self.login('test_vifib_member')
def stepLoginTestVifibUserAdmin(self, **kw):
self.login('test_vifib_user_admin')
def stepLoginTestVifibUserDeveloper(self, **kw):
self.login('test_vifib_user_developer')
def stepLoginERP5TypeTestCase(self, **kw):
self.login('ERP5TypeTestCase')
def stepLogout(self, **kw):
self.logout()
def checkDivergency(self):
# there shall be no divergency
current_skin = self.app.REQUEST.get('portal_skin', 'View')
try:
# Note: Worklists are cached, so in order to have next correct result
# clear cache
self.clearCache()
self.changeSkin('RSS')
diverged_document_list = self.portal.portal_catalog(
portal_type=self.portal.getPortalDeliveryTypeList(),
causality_state='!= solved'
)
self.assertFalse('to Solve' in self.portal.ERP5Site_viewWorklist(),
'There are unsolved deliveries: %s' % ','.join([
' '.join((q.getTitle(), q.getPath(), q.getCausalityState())) \
for q in diverged_document_list]))
finally:
self.changeSkin(current_skin)
def stepCheckSiteConsistency(self, **kw):
self.portal.portal_alarms.vifib_check_consistency.activeSense()
transaction.commit()
self.tic()
self.assertEqual([], self.portal.portal_alarms.vifib_check_consistency\
.Alarm_getConsistencyCheckReportLineList())
self.assertFalse(self.portal.portal_alarms.vifib_check_consistency.sense())
self.checkDivergency()
def stepCleanTic(self, **kw):
self.tic()
def stepTic(self, **kw):
def activateAlarm():
sm = getSecurityManager()
self.login()
try:
for alarm in self.portal.portal_alarms.contentValues():
if alarm.isEnabled() and (alarm.getId() not in \
('vifib_check_consistency',)):
alarm.activeSense()
finally:
setSecurityManager(sm)
if kw.get('sequence', None) is None:
# in case of using not in sequence commit transaction
transaction.commit()
# trigger activateAlarm before tic
activateAlarm()
transaction.commit()
self.tic()
# retrigger activateAlarm after tic
activateAlarm()
transaction.commit()
# tic after activateAlarm
self.tic()
try:
self.checkDivergency()
except AssertionError:
# try last time to solve deliveries
sm = getSecurityManager()
self.login()
try:
self.portal.portal_alarms.vifib_update_delivery_causality_state\
.activeSense()
transaction.commit()
self.tic()
self.portal.portal_alarms.vifib_solve_automatically.activeSense()
transaction.commit()
self.tic()
finally:
setSecurityManager(sm)
self.checkDivergency()
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from AccessControl import getSecurityManager
from VifibMixin import testVifibMixin
from Products.ERP5Type.tests.utils import DummyMailHost
import transaction
use_verbose_security = 0
if use_verbose_security:
import AccessControl
AccessControl.Implementation.setImplementation('python')
AccessControl.ImplPython.setDefaultBehaviors(
ownerous=True,
authenticated=True,
verbose=True)
class testVifibSecurityMixin(SecurityTestCase, testVifibMixin):
"""
Mixin class for security unit test of Vifib.
"""
run_all_test = 1
def createManagerAndLogin(self):
"""
Create a simple user in user_folder with manager rights.
This user will be used to initialize data in the method afterSetup
"""
self.getUserFolder()._doAddUser('manager', 'manager', ['Manager'], [])
self.login('manager')
def createERP5Users(self, user_dict):
"""
Create all ERP5 users needed for the test.
ERP5 user = Person object + Assignment object in erp5 person_module.
"""
portal = self.getPortal()
user = getSecurityManager().getUser()
user_name = user.getUserName()
# Check that user has access on the module
module = portal.getDefaultModule("Person")
if user_name != 'manager':
self.assertTrue(user.has_permission('Access contents information',
module))
self.assertTrue(user.has_permission('View',
module))
self.assertTrue(user.has_permission('Add portal content',
module))
self.assertFalse(user.has_permission('Modify portal content',
module))
# Create the Person.
for user_login, user_data in user_dict.items():
self.logMessage("Create user: %s" % user_login)
# Create the Person.
person = module.newContent(
portal_type='Person',
first_name=user_login,
reference=user_login,
default_email_text='romain@nexedi.com',
career_role='internal',
# password='hackme',
)
self.markManualCreation(person)
if user_name != 'manager':
self.assertTrue(user.has_permission('Access contents information',
person))
self.assertTrue(user.has_permission('View',
person))
self.assertTrue(user.has_permission('Add portal content',
person))
self.assertTrue(user.has_permission('Modify portal content',
person))
# Create the Assignment.
assignment = person.newContent(
portal_type = 'Assignment',
destination_project = user_data[0],
group = user_data[1],
function = user_data[2],
role = user_data[3],
start_date = '01/01/1900',
stop_date = '01/01/2900',
)
self.markManualCreation(assignment)
if user_name != 'manager':
self.assertTrue(user.has_permission('Access contents information',
assignment))
self.assertTrue(user.has_permission('View',
assignment))
self.assertTrue(user.has_permission('Add portal content',
assignment))
self.assertTrue(user.has_permission('Modify portal content',
assignment))
# User assignment to security groups is also required
self.portal.portal_workflow.doActionFor(
assignment,
'open_action')
# Reindexing is required for the security to work
transaction.commit()
self.tic()
def createAdministratorUser(self):
"""
Create Administrator user.
"""
user_dict = {
'administrator': [None, None, None, None]
}
self.createERP5Users(user_dict)
def stepLoginAsAdministrator(self, sequence=None, sequence_list=None, **kw):
"""
Login as administrator
"""
self.login("administrator")
def stepLoginAsManager(self, sequence=None, sequence_list=None, **kw):
"""
Login as manager
"""
self.login("manager")
def createVifibUsers(self):
"""
Create all users needed for the test
"""
self.createERP5Users(self.getUserDict())
def getUserDict(self):
"""
Return dict of users needed for the test
"""
return {}
def createVifibDocumentList(self):
"""
Call by bootstrapSite, can be overwritten
"""
pass
def validateRule(self):
"""
Call by bootstrapSite, can be overwritten
"""
pass
def bootstrapSite(self):
"""
Manager has to create an administrator user first.
"""
portal = self.getPortal()
if 'MailHost' in portal.objectIds():
portal.manage_delObjects(['MailHost'])
portal._setObject('MailHost', DummyMailHost('MailHost'))
portal.email_from_address = 'romain@nexedi.com'
portal.email_to_address = 'romain@nexedi.com'
self.clearCache()
self.logMessage("Bootstrap Vifib...")
self.logMessage("Create Manager")
self.createManagerAndLogin()
self.createVifibDocumentList()
self.validateRule()
self.logMessage("Create Administrator")
self.createAdministratorUser()
self.logout()
self.logMessage("Bootstrap Finished")
# XXX Hardcoded
# XXX-Fx: No security is defined so administrator has no rights
# so impossible to create vifib user with administrator
#self.login("administrator")
self.login('manager')
# XXX-Fx
# XXX XXX
self.createVifibUsers()
self.logout()
def stepLogout(self, sequence=None, sequence_list=None, **kw):
"""
Logout
"""
self.logout()
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibDefaultUseCase(TestVifibSlapWebServiceMixin):
def _getRegistrationInvoice(self, person):
transaction_list = self.portal.portal_catalog(
resource_relative_url=self.portal.portal_preferences\
.getPreferredRegistrationResource(),
portal_type="Invoice Line",
**{'movement.destination_uid': person.getUid()}
)
self.assertEquals(1, len(transaction_list))
return transaction_list[0].getObject().getParentValue()
def _getMonthlyInvoice(self, person):
line_list = self.portal.portal_catalog(
resource_relative_url=[
self.portal.portal_preferences.getPreferredInstanceSetupResource(),
self.portal.portal_preferences.getPreferredInstanceHostingResource(),
self.portal.portal_preferences.getPreferredInstanceCleanupResource(),
self.portal.portal_preferences.getPreferredInstanceUpdateResource(),
self.portal.portal_preferences.getPreferredInstanceSubscriptionResource(),
],
portal_type="Invoice Line",
**{'movement.destination_uid': person.getUid()}
)
transaction_list = [line.getParentValue() for line in line_list]
transaction_list = list(set(transaction_list))
self.assertEquals(1, len(transaction_list))
return transaction_list[0].getObject()
def stepCheckRegistrationAccounting(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
sale_invoice = self._getRegistrationInvoice(person)
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
self.assertEquals(
'sale_trade_condition_module/vifib_trade_condition',
sale_invoice.getSpecialise())
self.assertEquals(
'stopped',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
1, sale_invoice.getTotalPrice(), 3)
# 2 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(2, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_registration'][0]
vat_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0.836, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, vat_line.hasPrice())
self.assertAlmostEquals(0.196, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.836, vat_line.getQuantity(), 3)
# 3 transaction lines
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(3, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/sales'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
vat_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/coll_vat'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(-1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', receivable_line.getSpecialise())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(0.836, sale_line.getQuantity(), 3)
self.assertEquals('account_module/sales', sale_line.getSource())
self.assertEquals('account_module/purchase', sale_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', sale_line.getSpecialise())
self.assertAlmostEquals(1, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.164, vat_line.getQuantity(), 3)
self.assertEquals('account_module/coll_vat', vat_line.getSource())
self.assertEquals('account_module/refundable_vat', vat_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', vat_line.getSpecialise())
# XXX Check user interface display
self.assertEquals(
'Waiting for payment',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
# Check the payment transaction
payment_list = self.portal.portal_catalog(
portal_type="Payment Transaction",
destination_section_relative_url=person.getRelativeUrl(),
)
self.assertEquals(1, len(payment_list))
payment = payment_list[0]
sequence.edit(payment_transaction_uid=payment.getUid())
# Payment should have a causality link
self.assertEquals(sale_invoice.getRelativeUrl(), payment.getCausality())
# Check invoice creation
self.assertEquals(
None,
payment.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
payment.getSourceSection())
self.assertEquals(
None,
payment.getDestination())
self.assertEquals(
person.getRelativeUrl(),
payment.getDestinationSection())
self.assertEquals(
None,
payment.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
payment.getResource())
self.assertEquals(
None,
payment.getSpecialise())
self.assertEquals(
'started',
payment.getSimulationState())
self.assertAlmostEquals(
0, payment.getTotalPrice(), 3)
self.assertEquals('solved', payment.getCausalityState())
transaction_line_list = payment.contentValues(
portal_type="Accounting Transaction Line")
self.assertEquals(2, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/bank'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
self.assertEquals(True, receivable_line.hasPrice())
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', receivable_line.getSpecialise())
self.assertEquals(True, sale_line.hasPrice())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(-1, sale_line.getQuantity(), 3)
self.assertEquals('account_module/bank', sale_line.getSource())
self.assertEquals('account_module/bank', sale_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', sale_line.getSpecialise())
def stepCheckPaidRegistrationAccounting(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
sale_invoice = self._getRegistrationInvoice(person)
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
self.assertEquals(
'sale_trade_condition_module/vifib_trade_condition',
sale_invoice.getSpecialise())
self.assertEquals(
'stopped',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
1, sale_invoice.getTotalPrice(), 3)
# 2 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(2, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_registration'][0]
vat_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0.836, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, vat_line.hasPrice())
self.assertAlmostEquals(0.196, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.836, vat_line.getQuantity(), 3)
# 3 transaction lines
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(3, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/sales'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
vat_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/coll_vat'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(-1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', receivable_line.getSpecialise())
self.assertTrue(receivable_line.hasGroupingReference())
invoice_grouping_reference = receivable_line.getGroupingReference()
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(0.836, sale_line.getQuantity(), 3)
self.assertEquals('account_module/sales', sale_line.getSource())
self.assertEquals('account_module/purchase', sale_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', sale_line.getSpecialise())
self.assertAlmostEquals(1, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.164, vat_line.getQuantity(), 3)
self.assertEquals('account_module/coll_vat', vat_line.getSource())
self.assertEquals('account_module/refundable_vat', vat_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', vat_line.getSpecialise())
# XXX Check user interface display
self.assertEquals(
'Paid',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
# Check the payment transaction
payment_list = self.portal.portal_catalog(
portal_type="Payment Transaction",
destination_section_relative_url=person.getRelativeUrl(),
)
self.assertEquals(1, len(payment_list))
payment = payment_list[0]
sequence.edit(payment_transaction_uid=payment.getUid())
# Payment should have a causality link
self.assertEquals(sale_invoice.getRelativeUrl(), payment.getCausality())
# Check invoice creation
self.assertEquals(
None,
payment.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
payment.getSourceSection())
self.assertEquals(
None,
payment.getDestination())
self.assertEquals(
person.getRelativeUrl(),
payment.getDestinationSection())
self.assertEquals(
None,
payment.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
payment.getResource())
self.assertEquals(
None,
payment.getSpecialise())
self.assertEquals(
'stopped',
payment.getSimulationState())
self.assertAlmostEquals(
0, payment.getTotalPrice(), 3)
self.assertEquals('solved', payment.getCausalityState())
transaction_line_list = payment.contentValues(
portal_type="Accounting Transaction Line")
self.assertEquals(2, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/bank'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', receivable_line.getSpecialise())
self.assertTrue(receivable_line.hasGroupingReference())
self.assertEquals(invoice_grouping_reference,
receivable_line.getGroupingReference())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(-1, sale_line.getQuantity(), 3)
self.assertEquals('account_module/bank', sale_line.getSource())
self.assertEquals('account_module/bank', sale_line.getDestination())
self.assertEquals('sale_trade_condition_module/vifib_trade_condition', sale_line.getSpecialise())
def stepCheckSetupOngoingInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
# Check that 2 sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
)
self.assertEquals(2, len(transaction_list))
# Check that 1 ongoing sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
simulation_state='planned',
)
self.assertEquals(1, len(transaction_list))
sale_invoice = transaction_list[0].getObject()
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'planned',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
0.836, sale_invoice.getTotalPrice(), 3)
# 1 invoice line is expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(2, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(1, subscription_line.getQuantity())
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(0, len(transaction_line_list))
# XXX Check user interface display
self.assertEquals(
'Ongoing',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
def stepCheckHostingOngoingInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
# Check that 2 sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
)
self.assertEquals(2, len(transaction_list))
# Check that 1 ongoing sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
simulation_state='planned',
)
self.assertEquals(1, len(transaction_list))
sale_invoice = transaction_list[0].getObject()
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'planned',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
0.836, sale_invoice.getTotalPrice(), 3)
# 1 invoice line is expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(4, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(1, subscription_line.getQuantity())
self.assertEquals(True, hosting_line.hasPrice())
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(1, hosting_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(1, update_line.getQuantity())
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(0, len(transaction_line_list))
# XXX Check user interface display
self.assertEquals(
'Ongoing',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
def stepCheckDestroyOngoingInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
# Check that 2 sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
)
self.assertEquals(2, len(transaction_list))
# Check that 1 ongoing sale invoice has been generated for the user
transaction_list = self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
destination_section_relative_url=person.getRelativeUrl(),
simulation_state='planned',
)
self.assertEquals(1, len(transaction_list))
sale_invoice = transaction_list[0].getObject()
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'planned',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
0.836, sale_invoice.getTotalPrice(), 3)
# 1 invoice line is expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(5, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(1, subscription_line.getQuantity())
self.assertEquals(True, hosting_line.hasPrice())
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(1, hosting_line.getQuantity())
self.assertEquals(True, destroy_line.hasPrice())
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(0, len(transaction_line_list))
# XXX Check user interface display
self.assertEquals(
'Ongoing',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
def stepConfirmOngoingInvoice(self, sequence, **kw):
"""
"""
for invoice in self.portal.portal_catalog(
portal_type="Sale Invoice Transaction",
simulation_state="planned"):
invoice = invoice.getObject()
invoice.SaleInvoiceTransaction_confirmPlanned(
# force invoice confirmation (or moving to next month)
this_month=invoice.getStartDate() + 1
)
def stepCheckWaitingInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
sale_invoice = self._getMonthlyInvoice(person)
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'stopped',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
1, sale_invoice.getTotalPrice(), 3)
# 6 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(1, subscription_line.getQuantity())
self.assertEquals(True, hosting_line.hasPrice())
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(1, hosting_line.getQuantity())
self.assertEquals(True, destroy_line.hasPrice())
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(0.836, tax_line.getQuantity(), 3)
# 0 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(3, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/sales'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
vat_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/coll_vat'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(-1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertFalse(receivable_line.hasGroupingReference())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(0.836, sale_line.getQuantity(), 3)
self.assertEquals('account_module/sales', sale_line.getSource())
self.assertEquals('account_module/purchase', sale_line.getDestination())
self.assertAlmostEquals(1, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.164, vat_line.getQuantity(), 3)
self.assertEquals('account_module/coll_vat', vat_line.getSource())
self.assertEquals('account_module/refundable_vat', vat_line.getDestination())
# XXX Check user interface display
self.assertEquals(
'Waiting for payment',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
# Check the payment transaction
payment_list = self.portal.portal_catalog(
portal_type="Payment Transaction",
causality_uid=sale_invoice.getUid(),
)
self.assertEquals(1, len(payment_list))
payment = payment_list[0]
sequence.edit(payment_transaction_uid=payment.getUid())
# Payment should have a causality link
self.assertEquals(sale_invoice.getRelativeUrl(), payment.getCausality())
# Check invoice creation
self.assertEquals(
None,
payment.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
payment.getSourceSection())
self.assertEquals(
None,
payment.getDestination())
self.assertEquals(
person.getRelativeUrl(),
payment.getDestinationSection())
self.assertEquals(
None,
payment.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
payment.getResource())
self.assertEquals(
None,
payment.getSpecialise())
self.assertEquals(
'started',
payment.getSimulationState())
self.assertAlmostEquals(
0, payment.getTotalPrice(), 3)
self.assertEquals('solved', payment.getCausalityState())
transaction_line_list = payment.contentValues(
portal_type="Accounting Transaction Line")
self.assertEquals(2, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/bank'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
self.assertEquals(True, receivable_line.hasPrice())
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertFalse(receivable_line.hasGroupingReference())
self.assertEquals(True, sale_line.hasPrice())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(-1, sale_line.getQuantity(), 3)
self.assertEquals('account_module/bank', sale_line.getSource())
self.assertEquals('account_module/bank', sale_line.getDestination())
def stepCheckPaidInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
sale_invoice = self._getMonthlyInvoice(person)
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'stopped',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
1, sale_invoice.getTotalPrice(), 3)
# 5 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(1, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(1, subscription_line.getQuantity())
self.assertEquals(True, hosting_line.hasPrice())
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(1, hosting_line.getQuantity())
self.assertEquals(True, destroy_line.hasPrice())
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(1, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(2, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(0.836, tax_line.getQuantity(), 3)
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(3, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/sales'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
vat_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/coll_vat'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(-1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertTrue(receivable_line.hasGroupingReference())
invoice_grouping_reference = receivable_line.getGroupingReference()
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(0.836, sale_line.getQuantity(), 3)
self.assertEquals('account_module/sales', sale_line.getSource())
self.assertEquals('account_module/purchase', sale_line.getDestination())
self.assertAlmostEquals(1, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.164, vat_line.getQuantity(), 3)
self.assertEquals('account_module/coll_vat', vat_line.getSource())
self.assertEquals('account_module/refundable_vat', vat_line.getDestination())
# XXX Check user interface display
self.assertEquals(
'Paid',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
# Check the payment transaction
payment_list = self.portal.portal_catalog(
portal_type="Payment Transaction",
causality_uid=sale_invoice.getUid(),
)
self.assertEquals(1, len(payment_list))
payment = payment_list[0]
sequence.edit(payment_transaction_uid=payment.getUid())
# Payment should have a causality link
self.assertEquals(sale_invoice.getRelativeUrl(), payment.getCausality())
# Check invoice creation
self.assertEquals(
None,
payment.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
payment.getSourceSection())
self.assertEquals(
None,
payment.getDestination())
self.assertEquals(
person.getRelativeUrl(),
payment.getDestinationSection())
self.assertEquals(
None,
payment.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
payment.getResource())
self.assertEquals(
None,
payment.getSpecialise())
self.assertEquals(
'stopped',
payment.getSimulationState())
self.assertAlmostEquals(
0, payment.getTotalPrice(), 3)
self.assertEquals('solved', payment.getCausalityState())
transaction_line_list = payment.contentValues(
portal_type="Accounting Transaction Line")
self.assertEquals(2, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/bank'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
self.assertEquals(True, receivable_line.hasPrice())
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(1, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertTrue(receivable_line.hasGroupingReference())
self.assertEquals(invoice_grouping_reference,
receivable_line.getGroupingReference())
self.assertEquals(True, sale_line.hasPrice())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(-1, sale_line.getQuantity(), 3)
self.assertEquals('account_module/bank', sale_line.getSource())
self.assertEquals('account_module/bank', sale_line.getDestination())
def stepStoreCurrentToPostAccountingWorkflowCount(self, sequence,
**kw):
# there shall be no divergency
count = 0
current_skin = self.app.REQUEST.get('portal_skin', 'View')
try:
# Note: Worklists are cached, so in order to have next correct result
# clear cache
self.clearCache()
self.changeSkin('RSS')
for q in self.portal.ERP5Site_getWorklistObjectList():
if q.title.startswith("Accounting Transactions to Post"):
count = q.count
break
finally:
self.changeSkin(current_skin)
sequence['to_post_transaction_count'] = count
def stepCheckCurrentToPostAccountingWorkflowCount(self, sequence,
**kw):
# there shall be no divergency
count = 0
current_skin = self.app.REQUEST.get('portal_skin', 'View')
try:
# Note: Worklists are cached, so in order to have next correct result
# clear cache
self.clearCache()
self.changeSkin('RSS')
for q in self.portal.ERP5Site_getWorklistObjectList():
if q.title.startswith("Accounting Transactions to Post"):
count = q.count
break
finally:
self.changeSkin(current_skin)
self.assertEqual(count, sequence[
'to_post_transaction_count'])
def stepDecreaseCurrentToPostAccountingWorkflowCount(self,
sequence, **kw):
sequence['to_post_transaction_count'] = sequence[
'to_post_transaction_count'] - 1
def test_default_use_case(self):
"""Test full default use case.
User subscribes and pays 1 euro for registration.
He orders a software release with a 1 euro subscription price (vat
included) (everything else free).
Stopping his payment should generate the grouping reference on the related
invoice.
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_software_release_sequence_string + \
self.register_new_user_sequence_string + '\
LoginTestVifibAdmin \
StoreCurrentToPostAccountingWorkflowCount \
Logout \
LoginWebUser \
CheckRegistrationAccounting \
PayPayment \
Tic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
Logout \
LoginTestVifibAdmin \
DecreaseCurrentToPostAccountingWorkflowCount \
CheckCurrentToPostAccountingWorkflowCount \
Logout \
LoginWebUser \
CheckPaidRegistrationAccounting \
' + \
self.create_new_user_instance_sequence_string + '\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm\
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallDeliverSubscriptionSalePackingListAlarm \
CleanTic \
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
\
LoginWebUser \
CheckSetupOngoingInvoice \
SetSequenceSoftwareInstanceStateStarted \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
Logout \
LoginWebUser \
SetSequenceSoftwareInstanceStateStopped \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
Logout \
\
CallSlaposTriggerBuildAlarm \
CleanTic \
CallStopConfirmedSaleInvoiceTransactionAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
\
LoginWebUser \
CheckHostingOngoingInvoice \
\
SetSequenceSoftwareInstanceStateDestroyed \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceDestroyed \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceCleanupSalePackingListDelivered \
CheckComputerPartitionIsFree \
CheckOpenOrderLineRemoved \
Logout \
\
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
\
LoginWebUser \
CheckDestroyOngoingInvoice \
SlapLogout \
\
LoginERP5TypeTestCase \
ConfirmOngoingInvoice \
Tic \
\
SlapLogout \
Tic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallStopConfirmedSaleInvoiceTransactionAlarm \
CleanTic \
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm\
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallVifibPayzenUpdateConfirmedPaymentAlarm \
CleanTic \
\
LoginTestVifibAdmin \
StoreCurrentToPostAccountingWorkflowCount \
Logout \
\
LoginWebUser \
CheckWaitingInvoice \
Tic \
PayPayment \
Tic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CheckPaidInvoice \
LoginTestVifibAdmin \
DecreaseCurrentToPostAccountingWorkflowCount \
CheckCurrentToPostAccountingWorkflowCount \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckComplexInvoice(self, sequence, **kw):
"""
"""
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(sequence[
'web_user'])
sale_invoice = self._getMonthlyInvoice(person)
# Check invoice creation
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
sale_invoice.getSourceSection())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestination())
self.assertEquals(
person.getRelativeUrl(),
sale_invoice.getDestinationSection())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
sale_invoice.getResource())
# self.assertEquals(
# 'sale_trade_condition_module/vifib_trade_condition',
# sale_invoice.getSpecialise())
self.assertEquals(
'stopped',
sale_invoice.getSimulationState())
self.assertAlmostEquals(
2, sale_invoice.getTotalPrice(), 3)
# 5 invoice lines are expected
invoice_line_list = sale_invoice.contentValues(
portal_type="Invoice Line")
self.assertEquals(6, len(invoice_line_list))
service_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_setup'][0]
subscription_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_subscription'][0]
hosting_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_hosting'][0]
destroy_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_cleanup'][0]
update_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_instance_update'][0]
tax_line = [x for x in invoice_line_list \
if x.getResource() == 'service_module/vifib_tax'][0]
self.assertEquals(True, service_line.hasPrice())
self.assertAlmostEquals(0, service_line.getPrice(), 3)
self.assertEquals(2, service_line.getQuantity())
self.assertEquals(True, subscription_line.hasPrice())
self.assertAlmostEquals(0.836, subscription_line.getPrice(), 3)
self.assertEquals(2, subscription_line.getQuantity())
self.assertEquals(True, hosting_line.hasPrice())
self.assertAlmostEquals(0, hosting_line.getPrice(), 3)
self.assertEquals(3, hosting_line.getQuantity())
self.assertEquals(True, destroy_line.hasPrice())
self.assertAlmostEquals(0, destroy_line.getPrice(), 3)
self.assertEquals(2, destroy_line.getQuantity())
self.assertEquals(True, update_line.hasPrice())
self.assertAlmostEquals(0, update_line.getPrice(), 3)
self.assertEquals(6, update_line.getQuantity())
self.assertEquals(True, tax_line.hasPrice())
self.assertAlmostEquals(0.196, tax_line.getPrice(), 3)
self.assertAlmostEquals(1.672, tax_line.getQuantity(), 3)
# 3 transaction line
transaction_line_list = sale_invoice.contentValues(
portal_type="Sale Invoice Transaction Line")
self.assertEquals(3, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/sales'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
vat_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/coll_vat'][0]
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(-2, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertTrue(receivable_line.hasGroupingReference())
invoice_grouping_reference = receivable_line.getGroupingReference()
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(1.672, sale_line.getQuantity(), 3)
self.assertEquals('account_module/sales', sale_line.getSource())
self.assertEquals('account_module/purchase', sale_line.getDestination())
self.assertAlmostEquals(1, vat_line.getPrice(), 3)
self.assertAlmostEquals(0.328, vat_line.getQuantity(), 3)
self.assertEquals('account_module/coll_vat', vat_line.getSource())
self.assertEquals('account_module/refundable_vat', vat_line.getDestination())
# XXX Check user interface display
self.assertEquals(
'Paid',
sale_invoice.portal_skins.vifib_hosting.AccountingTransaction_getPaymentState())
self.assertEquals('solved', sale_invoice.getCausalityState())
# Check the payment transaction
payment_list = self.portal.portal_catalog(
portal_type="Payment Transaction",
causality_uid=sale_invoice.getUid(),
)
self.assertEquals(1, len(payment_list))
payment = payment_list[0]
sequence.edit(payment_transaction_uid=payment.getUid())
# Payment should have a causality link
self.assertEquals(sale_invoice.getRelativeUrl(), payment.getCausality())
# Check invoice creation
self.assertEquals(
None,
payment.getSource())
self.assertEquals(
'organisation_module/vifib_internet',
payment.getSourceSection())
self.assertEquals(
None,
payment.getDestination())
self.assertEquals(
person.getRelativeUrl(),
payment.getDestinationSection())
self.assertEquals(
None,
payment.getPriceCurrency())
self.assertEquals(
'currency_module/EUR',
payment.getResource())
self.assertEquals(
None,
payment.getSpecialise())
self.assertEquals(
'stopped',
payment.getSimulationState())
self.assertAlmostEquals(
0, payment.getTotalPrice(), 3)
self.assertEquals('solved', payment.getCausalityState())
transaction_line_list = payment.contentValues(
portal_type="Accounting Transaction Line")
self.assertEquals(2, len(transaction_line_list))
sale_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/bank'][0]
receivable_line = [x for x in transaction_line_list \
if x.getSource() == 'account_module/receivable'][0]
self.assertEquals(True, receivable_line.hasPrice())
self.assertAlmostEquals(1, receivable_line.getPrice(), 3)
self.assertAlmostEquals(2, receivable_line.getQuantity(), 3)
self.assertEquals('account_module/receivable', receivable_line.getSource())
self.assertEquals('account_module/payable', receivable_line.getDestination())
self.assertTrue(receivable_line.hasGroupingReference())
self.assertEquals(invoice_grouping_reference,
receivable_line.getGroupingReference())
self.assertEquals(True, sale_line.hasPrice())
self.assertAlmostEquals(1, sale_line.getPrice(), 3)
self.assertAlmostEquals(-2, sale_line.getQuantity(), 3)
self.assertEquals('account_module/bank', sale_line.getSource())
self.assertEquals('account_module/bank', sale_line.getDestination())
def test_aggregated_use_case(self):
"""Test a more complex use case with many packing list agregated
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_software_release_sequence_string + \
self.register_new_user_sequence_string + '\
LoginWebUser \
CheckRegistrationAccounting \
PayPayment \
Tic \
Logout \
LoginWebUser \
' + \
self.create_new_user_instance_sequence_string + '\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm\
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallDeliverSubscriptionSalePackingListAlarm \
CleanTic \
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
\
LoginWebUser \
SetSequenceSoftwareInstanceStateStarted \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
Logout \
LoginWebUser \
SetSequenceSoftwareInstanceStateStopped \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
Logout \
\
LoginWebUser \
SetSequenceSoftwareInstanceStateStarted \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
Logout \
LoginWebUser \
SetSequenceSoftwareInstanceStateStopped \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
Logout \
\
LoginWebUser \
SetSequenceSoftwareInstanceStateDestroyed \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceDestroyed \
Tic \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceCleanupSalePackingListDelivered \
CheckComputerPartitionIsFree \
CheckOpenOrderLineRemoved \
Logout \
\
' + \
self.create_new_user_instance_sequence_string + '\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginWebUser \
SetSequenceSoftwareInstanceStateStarted \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
Logout \
LoginWebUser \
SetSequenceSoftwareInstanceStateStopped \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
Logout \
\
LoginWebUser \
SetSequenceSoftwareInstanceStateDestroyed \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceDestroyed \
Tic \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceCleanupSalePackingListDelivered \
CheckComputerPartitionIsFree \
CheckOpenOrderLineRemoved \
Logout \
\
LoginERP5TypeTestCase \
ConfirmOngoingInvoice \
Tic \
\
SlapLogout \
Tic \
\
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallStopConfirmedSaleInvoiceTransactionAlarm \
CleanTic \
CallVifibExpandDeliveryLineAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
CallSlaposUpdateDeliveryCausalityStateAlarm \
CleanTic \
CallVifibSolveAutomaticallyAlarm \
CleanTic \
CallVifibPayzenUpdateConfirmedPaymentAlarm \
CleanTic \
\
LoginWebUser \
PayPayment \
Tic \
CheckComplexInvoice \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibDefaultUseCase))
return suite
import unittest
from Products.ERP5Type.tests.Sequence import SequenceList
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from Products.ERP5Type.DateUtils import getClosestDate, addToDate
from DateTime import DateTime
class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
def stepCheckSubscriptionSalePackingListCoverage(self, sequence, **kw):
hosting_subscription = self.portal.portal_catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
delivery_list = self.portal.portal_catalog(
portal_type='Sale Packing List',
causality_relative_url=hosting_subscription.getRelativeUrl(),
sort_on=(('delivery.start_date', 'desc'),)
)
# is next month covered?
self.assertEqual(1, len(delivery_list))
instance_setup_delivery = self.portal.portal_catalog.getResultValue(
portal_type='Sale Packing List Line',
default_aggregate_uid=sequence['software_instance_uid'],
resource_relative_url=self.portal.portal_preferences\
.getPreferredInstanceSetupResource()).getParentValue()
self.assertEqual('delivered', instance_setup_delivery.getSimulationState())
start_date = None
for item in self.portal.portal_workflow.getInfoFor(
ob=instance_setup_delivery, name='history', wf_id='packing_list_workflow'):
if item.get('simulation_state') == 'stopped':
start_date = item.get('time')
break
start_date = getClosestDate(target_date=start_date, precision='day')
while start_date.day() >= 29:
start_date = addToDate(start_date, to_add={'day': -1})
stop_date = addToDate(start_date, to_add={'month': 1})
idx = 0
for delivery in delivery_list:
self.assertEqual(start_date, delivery.getStartDate())
self.assertEqual(stop_date, delivery.getStopDate())
self.assertEqual(hosting_subscription.getRelativeUrl(),
delivery.getCausality())
delivery_line_list = \
delivery.contentValues(portal_type="Sale Packing List Line")
self.assertEquals(1, len(delivery_line_list))
delivery_line = delivery_line_list[0]
self.assertEquals("organisation_module/vifib_internet",
delivery.getSource())
self.assertEquals("organisation_module/vifib_internet",
delivery.getSourceSection())
self.assertEquals("person_module/test_vifib_customer",
delivery.getDestination())
self.assertEquals("person_module/test_vifib_customer",
delivery.getDestinationSection())
self.assertEquals("currency_module/EUR",
delivery.getPriceCurrency())
# check sale packing list line related property
self.assertEquals("service_module/vifib_instance_subscription",
delivery_line.getResource())
self.assertEquals(1,
delivery_line.getQuantity())
self.assertEquals("unit/piece",
delivery_line.getQuantityUnit())
self.assertEquals(0.83612040133800003,
delivery_line.getPrice())
# fetch open order, open order line and subscription
person = self.portal.person_module['test_vifib_customer']
open_order = self.portal.portal_catalog.getResultValue(
default_destination_decision_uid=person.getUid(),
portal_type="Open Sale Order",
validation_state='validated')
open_order_line = \
open_order.contentValues(portal_type="Open Sale Order Line")[0]
# check related property
self.assertEquals(open_order_line.getSpecialise(),
delivery.getSpecialise())
idx += 1
def stepCheckHostingSubscriptionInitialDocumentCoverage(self, sequence, **kw):
catalog = self.portal.portal_catalog
hosting_resource = self.portal.portal_preferences\
.getPreferredInstanceHostingResource()
setup_resource = self.portal.portal_preferences\
.getPreferredInstanceSetupResource()
subscription_resource = self.portal.portal_preferences\
.getPreferredInstanceSubscriptionResource()
sequence.edit(
hosting_resource=hosting_resource,
setup_resource=setup_resource,
subscription_resource=subscription_resource
)
hosting_subscription = catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
hosting_subscription_url = hosting_subscription.getRelativeUrl()
# hosting is confirmed, so no invoice
hosting_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=hosting_resource)
self.assertEqual(1, len(hosting_delivery_line_list))
self.assertEqual('confirmed', hosting_delivery_line_list[0]\
.getSimulationState())
hosting_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=hosting_resource)
self.assertEqual(0, len(hosting_invoice_line_list))
# setup is delivered, and has there is invoice
setup_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=setup_resource)
self.assertEqual(1, len(setup_delivery_line_list))
self.assertEqual('delivered', setup_delivery_line_list[0]\
.getSimulationState())
setup_invoice_line_list = catalog(portal_type='Invoice Line',
resource_relative_url=setup_resource)
self.assertEqual(1, len(setup_invoice_line_list))
self.assertEqual('planned', setup_invoice_line_list[0]\
.getSimulationState())
# there are 2 confirmed subscription, so no invoice
subscription_delivery_line_list = catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=subscription_resource,
sort_on=(('movement.start_date', 'desc'),)
)
self.assertEqual(1, len(subscription_delivery_line_list))
self.assertEqual(['delivered'], [q.getSimulationState() for \
q in subscription_delivery_line_list])
subscription_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=subscription_resource)
self.assertEqual(0, len(subscription_invoice_line_list))
# invoice shall be solved
invoice = setup_invoice_line_list[0].getParentValue()
self.assertEqual('solved', invoice.getCausalityState())
# invoice shall have no causality
self.assertEqual(invoice.getCausalityList(), [])
# there shall be no payment transaction related
self.assertEqual([], invoice.getCausalityRelatedList(
portal_type='Payment Transaction'))
sequence.edit(
subscription_delivery_uid_list=[q.getParentValue().getUid() for q in \
subscription_delivery_line_list]
)
def stepSelectNextSubscriptionDelivery(self, sequence, **kw):
subscription_delivery_uid_list = sequence['subscription_delivery_uid_list']
subscription_delivery_uid_list.reverse()
subscription_delivery_uid = subscription_delivery_uid_list.pop()
subscription_delivery_uid_list.reverse()
sequence.edit(
subscription_delivery_uid_list=subscription_delivery_uid_list,
subscription_delivery_uid=subscription_delivery_uid
)
def stepCheckHostingSubscriptionStoppedDocumentCoverage(self, sequence, **kw):
catalog = self.portal.portal_catalog
hosting_subscription = catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
hosting_subscription_url = hosting_subscription.getRelativeUrl()
# hosting is confirmed, so no invoice
hosting_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(1, len(hosting_delivery_line_list))
self.assertEqual('confirmed', hosting_delivery_line_list[0]\
.getSimulationState())
hosting_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(0, len(hosting_invoice_line_list))
# setup is delivered, and has there is invoice
setup_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_delivery_line_list))
self.assertEqual('delivered', setup_delivery_line_list[0]\
.getSimulationState())
setup_invoice_line_list = catalog(portal_type='Invoice Line',
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_invoice_line_list))
self.assertEqual('planned', setup_invoice_line_list[0]\
.getSimulationState())
# there are 1 confirmed and 1 stopped subscription, so 1 invoice line
subscription_delivery_line_list = catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(1, len(subscription_delivery_line_list))
self.assertEqual(['delivered'],
sorted([q.getSimulationState() for \
q in subscription_delivery_line_list]))
subscription_invoice_line_list = catalog(portal_type='Invoice Line',
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(1, len(subscription_invoice_line_list))
self.assertEqual('planned', subscription_invoice_line_list[0]\
.getSimulationState())
# there are two invoice lines sharing same invoice
self.assertEqual(
setup_invoice_line_list[0].getParentValue().getRelativeUrl(),
subscription_invoice_line_list[0].getParentValue().getRelativeUrl()
)
# invoice shall be solved
self.assertEqual('solved', setup_invoice_line_list[0].getCausalityState())
# invoice shall have no causality
self.assertEqual(setup_invoice_line_list[0].getParentValue()\
.getCausalityList(), [])
def stepSelectPlannedInvoice(self, sequence, **kw):
invoice_line = self.portal.portal_catalog.getResultValue(
portal_type='Invoice Line',
simulation_state='planned'
)
# there shall be no payment transaction related
self.assertEqual([], invoice_line.getParentValue().getCausalityRelatedList(
portal_type='Payment Transaction'))
sequence.edit(invoice_uid=invoice_line.getParentValue().getUid())
def stepConfirmInvoice(self, sequence, **kw):
self.portal.portal_catalog.getResultValue(
uid=sequence['invoice_uid']).confirm()
def stepCheckHostingSubscriptionConfirmedInvoiceDocumentCoverage(self,
sequence, **kw):
catalog = self.portal.portal_catalog
hosting_subscription = catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
hosting_subscription_url = hosting_subscription.getRelativeUrl()
# hosting is confirmed, so no invoice
hosting_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(1, len(hosting_delivery_line_list))
self.assertEqual('confirmed', hosting_delivery_line_list[0]\
.getSimulationState())
hosting_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(0, len(hosting_invoice_line_list))
# setup is delivered, and has there is invoice
setup_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_delivery_line_list))
self.assertEqual('delivered', setup_delivery_line_list[0]\
.getSimulationState())
setup_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_invoice_line_list))
self.assertEqual('confirmed', setup_invoice_line_list[0]\
.getSimulationState())
# there are 10 confirmed and 2 stopped subscription, so 2 invoice line
subscription_delivery_line_list = catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_delivery_line_list))
self.assertEqual(['stopped'] * 2,
sorted([q.getSimulationState() for \
q in subscription_delivery_line_list]))
subscription_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_invoice_line_list))
self.assertEqual(['confirmed', 'planned'],
sorted([q.getSimulationState() for q in subscription_invoice_line_list]))
# there are three invoice lines, where two share same invoice
# and other is on new one
self.assertEqual(
setup_invoice_line_list[0].getParentValue().getRelativeUrl(),
[q.getParentValue().getRelativeUrl() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'confirmed'][0]
)
self.assertNotEqual(
setup_invoice_line_list[0].getParentValue().getRelativeUrl(),
[q.getParentValue().getRelativeUrl() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'planned'][0]
)
confirmed_invoice = setup_invoice_line_list[0].getParentValue()
planned_invoice = [q.getParentValue() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'planned'][0]
# invoices shall be solved
self.assertEqual('solved', planned_invoice.getCausalityState())
self.assertEqual('solved', confirmed_invoice.getCausalityState())
# there shall be no payment transaction related
self.assertEqual([], planned_invoice.getCausalityRelatedList(
portal_type='Payment Transaction'))
self.assertEqual([], confirmed_invoice.getCausalityRelatedList(
portal_type='Payment Transaction'))
# confirmed invoice shall have no causality
self.assertEqual(confirmed_invoice.getCausalityList(), [])
# planned invoice shall have no causality
self.assertEqual(planned_invoice.getCausalityList(), [])
def stepStartInvoice(self, sequence, **kw):
self.portal.portal_catalog.getResultValue(
uid=sequence['invoice_uid']).start()
def stepStopInvoice(self, sequence, **kw):
self.portal.portal_catalog.getResultValue(
uid=sequence['invoice_uid']).stop()
def stepCheckHostingSubscriptionStoppedInvoiceDocumentCoverage(self,
sequence, **kw):
catalog = self.portal.portal_catalog
hosting_subscription = catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
hosting_subscription_url = hosting_subscription.getRelativeUrl()
# hosting is confirmed, so no invoice
hosting_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(1, len(hosting_delivery_line_list))
self.assertEqual('confirmed', hosting_delivery_line_list[0]\
.getSimulationState())
hosting_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(0, len(hosting_invoice_line_list))
# setup is delivered, and has there is invoice
setup_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_delivery_line_list))
self.assertEqual('delivered', setup_delivery_line_list[0]\
.getSimulationState())
setup_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_invoice_line_list))
self.assertEqual('stopped', setup_invoice_line_list[0]\
.getSimulationState())
# there are 10 confirmed and 2 stopped subscription, so 2 invoice line
subscription_delivery_line_list = catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_delivery_line_list))
self.assertEqual(['stopped'] * 2,
sorted([q.getSimulationState() for \
q in subscription_delivery_line_list]))
subscription_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_invoice_line_list))
self.assertEqual(['planned', 'stopped'],
sorted([q.getSimulationState() for q in subscription_invoice_line_list]))
# there are three invoice lines, where two share same invoice
# and other is on new one
self.assertEqual(
setup_invoice_line_list[0].getParentValue().getRelativeUrl(),
[q.getParentValue().getRelativeUrl() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'stopped'][0]
)
self.assertNotEqual(
setup_invoice_line_list[0].getParentValue().getRelativeUrl(),
[q.getParentValue().getRelativeUrl() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'planned'][0]
)
stopped_invoice = setup_invoice_line_list[0].getParentValue()
planned_invoice = [q.getParentValue() for q in \
subscription_invoice_line_list \
if q.getSimulationState() == 'planned'][0]
# invoices shall be solved
self.assertEqual('solved', planned_invoice.getCausalityState())
self.assertEqual('solved', stopped_invoice.getCausalityState())
# there shall be no payment transaction related to planned invoice
self.assertEqual([], planned_invoice.getCausalityRelatedList(
portal_type='Payment Transaction'))
# there shall be one payment transaction related to stopped invoice
payment_transaction_list = stopped_invoice.getCausalityRelatedValueList(
portal_type='Payment Transaction')
self.assertEqual(1, len(payment_transaction_list))
payment_transaction = payment_transaction_list[0]
# this payment transaction shall be planned and solved
self.assertEqual('planned', payment_transaction.getSimulationState())
self.assertEqual('solved', payment_transaction.getCausalityState())
# only this invoice shall be covered by this payment transaction
self.assertEqual(stopped_invoice.getRelativeUrl(),
payment_transaction.getCausality())
# this payment shall fully pay the invoice
self.assertEqual(stopped_invoice.getTotalPrice(),
-1 * payment_transaction.PaymentTransaction_getTotalPayablePrice())
# Stopped invoice shall have no causality
self.assertEqual(stopped_invoice.getCausalityList(), [])
# planned invoice shall have no causality
self.assertEqual(planned_invoice.getCausalityList(), [])
def stepCheckHostingSubscriptionTwoStoppedInvoiceDocumentCoverage(self,
sequence, **kw):
catalog = self.portal.portal_catalog
hosting_subscription = catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
hosting_subscription_url = hosting_subscription.getRelativeUrl()
# hosting is confirmed, so no invoice
hosting_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(1, len(hosting_delivery_line_list))
self.assertEqual('confirmed', hosting_delivery_line_list[0]\
.getSimulationState())
hosting_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['hosting_resource'])
self.assertEqual(0, len(hosting_invoice_line_list))
# setup is delivered, and has there is invoice
setup_delivery_line_list = catalog(portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_delivery_line_list))
self.assertEqual('delivered', setup_delivery_line_list[0]\
.getSimulationState())
setup_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['setup_resource'])
self.assertEqual(1, len(setup_invoice_line_list))
self.assertEqual('stopped', setup_invoice_line_list[0]\
.getSimulationState())
# there are 10 confirmed and 2 stopped subscription, so 2 invoice line
subscription_delivery_line_list = catalog(
portal_type='Sale Packing List Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_delivery_line_list))
self.assertEqual(['stopped'] * 2,
sorted([q.getSimulationState() for \
q in subscription_delivery_line_list]))
subscription_invoice_line_list = catalog(portal_type='Invoice Line',
aggregate_relative_url=hosting_subscription_url,
resource_relative_url=sequence['subscription_resource'])
self.assertEqual(2, len(subscription_invoice_line_list))
self.assertEqual(['stopped', 'stopped'],
sorted([q.getSimulationState() for q in subscription_invoice_line_list]))
# there are three invoice lines, where two share same invoice
# and other is on other one
first_invoice = setup_invoice_line_list[0].getParentValue()
second_invoice = [q.getParentValue() for q in \
subscription_invoice_line_list \
if q.getParentValue().getUid() != first_invoice.getUid()][0]
# invoices shall be solved
self.assertEqual('solved', first_invoice.getCausalityState())
self.assertEqual('solved', second_invoice.getCausalityState())
# both invoice shall have shared payment transaction
payment_transaction_list = first_invoice.getCausalityRelatedValueList(
portal_type='Payment Transaction')
self.assertEqual(1, len(payment_transaction_list))
payment_transaction = payment_transaction_list[0]
self.assertEqual([payment_transaction.getRelativeUrl()],
second_invoice.getCausalityRelatedList(
portal_type='Payment Transaction'))
# this payment transaction shall be planned and solved
self.assertEqual('planned', payment_transaction.getSimulationState())
self.assertEqual('solved', payment_transaction.getCausalityState())
# this payment shall fully pay both invoices
self.assertEqual(
first_invoice.getTotalPrice() + second_invoice.getTotalPrice(),
-1 * payment_transaction.PaymentTransaction_getTotalPayablePrice())
sequence.edit(payment_transaction_uid=payment_transaction.getUid())
def stepConfirmPayment(self, sequence, **kw):
self.portal.portal_catalog.getResultValue(
uid=sequence['payment_transaction_uid']).confirm()
def stepCheckPayment(self, sequence, **kw):
payment_transaction = self.portal.portal_catalog.getResultValue(
uid=sequence['payment_transaction_uid'])
self.assertEqual('confirmed', payment_transaction.getSimulationState())
self.assertEqual('solved', payment_transaction.getCausalityState())
def stepInvoiceSetStartDatePreviousMonth(self, sequence, **kw):
invoice = self.portal.portal_catalog.getResultValue(
uid=sequence['invoice_uid'])
invoice.setStartDate(getClosestDate(target_date=DateTime())-1)
def test_OpenOrder_sale_packing_list(self):
"""
Check that sale_packing_list is generated properly from simulation
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + \
"""
LoginDefaultUser
CallSlaposTriggerBuildAlarm
Tic
CheckSubscriptionSalePackingListCoverage
CallSlaposTriggerBuildAlarm
Tic
CallSlaposUpdateDeliveryCausalityStateAlarm
CleanTic
CallVifibSolveAutomaticallyAlarm
CleanTic
# Nothing shall change
CheckHostingSubscriptionInitialDocumentCoverage
# Stop first Subscription delivery and after triggering build check
# that invoice got updated
SelectNextSubscriptionDelivery
Tic
CallSlaposTriggerBuildAlarm
Tic
CheckHostingSubscriptionStoppedDocumentCoverage
# proff that alarm will ignore this month invoices
CallConfirmPlannedSaleInvoiceTransactionAlarm
Tic
CallStopConfirmedSaleInvoiceTransactionAlarm
Tic
CheckHostingSubscriptionStoppedDocumentCoverage
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
# # Confirm current invoice and stop next delivery. After triggering build
# # new planned invoice shall be available.
#
# SelectPlannedInvoice
# ConfirmInvoice
# Tic
#
# SelectNextSubscriptionDelivery
# Tic
#
# CallSlaposTriggerBuildAlarm
# Tic
#
# CheckHostingSubscriptionConfirmedInvoiceDocumentCoverage
#
# # Lets check the payment
#
# StartInvoice
# StopInvoice
# Tic
#
# CallSlaposTriggerBuildAlarm
# Tic
#
# CheckHostingSubscriptionStoppedInvoiceDocumentCoverage
#
# # Proof that alarm is capable to stop previous month invoice
# SelectPlannedInvoice
# InvoiceSetStartDatePreviousMonth
# Tic
# CallConfirmPlannedSaleInvoiceTransactionAlarm
# Tic
# CallStopConfirmedSaleInvoiceTransactionAlarm
# Tic
#
# # Payment should cover both invoices
# CallSlaposTriggerBuildAlarm
# Tic
#
# CheckHostingSubscriptionTwoStoppedInvoiceDocumentCoverage
#
# ConfirmPayment
# Tic
# CheckPayment
#
# """
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibInstanceHostingRelatedDocument))
return suite
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import unittest
from VifibMixin import testVifibMixin
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from slapos.tests import interface
# from slapos.slap.tests import testslap
"""Test to check slap in ERP5 test runner
Some tests are just wrapping slap egg in ERP5TypeTestCase
Others are using generated site with data and use such site as server to test
slap as client library.
"""
class VifibServerMixin(testVifibMixin):
def afterSetUp(self):
testVifibMixin.afterSetUp(self)
self.server_url = self.portal.portal_slap.absolute_url()
class TestSlapInterface(ERP5TypeTestCase, interface.TestInterface):
"""Wrapper class for TestInterface
Note: This is here because there is no test runner for eggs."""
# class TestSlapSlap(testVifibMixin, testslap.TestSlap):
# """Wrapper class for TestSlap"""
#
# class TestSlapComputer(VifibServerMixin, testslap.TestComputer):
# """Wrapper class for TestComputer"""
#
# class TestSlapComputerPartition(VifibServerMixin,
# testslap.TestComputerPartition):
# """Wrapper class for TestComputerPartition"""
#
# class TestSlapSoftwareRelease(VifibServerMixin,
# testslap.TestSoftwareRelease):
# """Wrapper class for TestSoftwareRelease"""
#
# class TestSlapOpenOrder(VifibServerMixin,
# testslap.TestOpenOrder):
# """Wrapper class for TestSoftwareRelease"""
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestSlapInterface))
# suite.addTest(unittest.makeSuite(TestSlapSlap))
# suite.addTest(unittest.makeSuite(TestSlapComputer))
# suite.addTest(unittest.makeSuite(TestSlapComputerPartition))
# suite.addTest(unittest.makeSuite(TestSlapSoftwareRelease))
# suite.addTest(unittest.makeSuite(TestSlapOpenOrder))
return suite
import unittest
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.DateUtils import getClosestDate, addToDate
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from DateTime.DateTime import DateTime
class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
def stepCheckSimulationMovement(self, sequence, **kw):
# find related documents: open order, open order line,
# subscription item, etc.
person = self.portal.person_module['test_vifib_customer']
open_order = self.portal.portal_catalog.getResultValue(
default_destination_decision_uid=person.getUid(),
validation_state='validated',
portal_type="Open Sale Order")
open_order_line_list = \
open_order.contentValues(portal_type="Open Sale Order Line")
self.assertEquals(1, len(open_order_line_list))
open_order_line = open_order_line_list[0]
hosting_subscription = \
open_order_line.getAggregateValue(portal_type="Hosting Subscription")
applied_rule = \
hosting_subscription.getCausalityRelatedValue(portal_type="Applied Rule")
self.assertEquals(
"portal_rules/vifib_subscription_item_rule",
applied_rule.getSpecialise())
# check start date and stop date of the subscription item,
# currently there is 1 month
instance_setup_delivery = self.portal.portal_catalog.getResultValue(
portal_type='Sale Packing List Line',
default_aggregate_uid=sequence['software_instance_uid'],
resource_relative_url=self.portal.portal_preferences\
.getPreferredInstanceSetupResource()).getParentValue()
self.assertEqual('delivered', instance_setup_delivery.getSimulationState())
start_date = None
for item in self.portal.portal_workflow.getInfoFor(
ob=instance_setup_delivery, name='history', wf_id='packing_list_workflow'):
if item.get('simulation_state') == 'delivered':
start_date = item.get('time')
break
start_date = getClosestDate(target_date=start_date, precision='day')
while start_date.day() >= 29:
start_date = addToDate(start_date, to_add={'day': -1})
stop_date = addToDate(start_date, to_add={'month': 1})
# check periodicity, should be first day of each month
self.assertEquals(
None, hosting_subscription.getPeriodicityMinuteFrequency())
self.assertEquals(
[0], hosting_subscription.getPeriodicityMinuteList())
self.assertEquals(
None, hosting_subscription.getPeriodicityHourFrequency())
self.assertEquals(
[0], hosting_subscription.getPeriodicityHourList())
self.assertEquals(
None, hosting_subscription.getPeriodicityDayFrequency())
self.assertEquals(
None, hosting_subscription.getPeriodicityMonthFrequency())
self.assertEquals(
[start_date.day()], hosting_subscription.getPeriodicityMonthDayList())
self.assertEquals(
None, hosting_subscription.getPeriodicityWeekFrequency())
self.assertEqual(start_date, open_order_line.getStartDate())
self.assertEqual(stop_date, open_order_line.getStopDate())
simulation_movement_list = self.portal.portal_catalog(
portal_type='Simulation Movement',
parent_uid=applied_rule.getUid(),
sort_on=(('movement.start_date', 'desc'),)
)
# Check that simulation is created by the periodicity for one month
self.assertEquals(1,
len(simulation_movement_list))
# Check the list of expected simulation
idx = 0
for simulation_movement in simulation_movement_list:
# Check simulation movement property
self.assertEquals(1.0,
simulation_movement.getQuantity())
self.assertEquals("unit/piece",
simulation_movement.getQuantityUnit())
self.assertEquals(0.83612040133800003,
simulation_movement.getPrice())
self.assertEquals("currency_module/EUR",
simulation_movement.getPriceCurrency())
# XXX supplier
self.assertEquals("organisation_module/vifib_internet",
simulation_movement.getSource())
self.assertEquals("organisation_module/vifib_internet",
simulation_movement.getSourceSection())
# XXX customer
self.assertEquals("person_module/test_vifib_customer",
simulation_movement.getDestination())
self.assertEquals("person_module/test_vifib_customer",
simulation_movement.getDestinationSection())
self.assertEquals(open_order_line.getSpecialise(),
simulation_movement.getSpecialise())
self.assertEquals("service_module/vifib_instance_subscription",
simulation_movement.getResource())
self.assertEquals("vifib/delivery",
simulation_movement.getTradePhase())
self.assertEquals(None,
simulation_movement.getAggregate(
portal_type="Computer Partition"))
self.assertEquals(None,
simulation_movement.getAggregate(
portal_type="Software Instance"))
self.assertEquals(hosting_subscription.getRelativeUrl(),
simulation_movement.getAggregate(
portal_type="Hosting Subscription"))
self.assertEquals(None,
simulation_movement.getAggregate(
portal_type="Software Release"))
self.assertEqual(start_date, simulation_movement.getStartDate())
self.assertEqual(stop_date, simulation_movement.getStopDate())
# delivered already...
self.assertNotEqual(None, simulation_movement.getDelivery())
self.assertEqual('Sale Packing List Line',
simulation_movement.getDeliveryValue().getPortalType())
# ...so no buildable
self.assertFalse(simulation_movement.isBuildable())
# delivered...
self.assertEqual('delivered', simulation_movement.getSimulationState())
# ...so invoice rule applied
self.assertEqual(1,
len(simulation_movement.contentValues(portal_type="Applied Rule")))
# ...with one simulation movement
invoice_applied_rule = simulation_movement.contentValues(
portal_type="Applied Rule")[0]
self.assertEqual(1, len(invoice_applied_rule.contentValues()))
# check next simulation movement
idx += 1
def stepIncreaseOpenOrderCoverage(self, sequence, **kw):
self.portal.portal_alarms.vifib_person_update_open_order.\
Alarm_updatePersonOpenOrder(
tag='test_tag', fixit=False,
params={'stop_date': addToDate(getClosestDate(target_date=DateTime(),
precision='month', before=1), month=3)})
def stepCheckThreeTopLevelSimulationMovement(self, sequence, **kw):
hosting_subscription = self.portal.portal_catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
# 2 open order lines:
# * one with start date and stop date
# * one with stop date extended by test
self.assertEqual(2, self.portal.portal_catalog.countResults(
default_aggregate_uid=sequence['hosting_subscription_uid'],
portal_type='Open Sale Order Line')[0][0]
)
applied_rule = \
hosting_subscription.getCausalityRelatedValue(portal_type="Applied Rule")
self.assertEquals(
"portal_rules/vifib_subscription_item_rule",
applied_rule.getSpecialise())
simulation_movement_list = self.portal.portal_catalog(
portal_type='Simulation Movement',
parent_uid=applied_rule.getUid(),
sort_on=(('movement.start_date', 'desc'),)
)
# Check that simulation is created by the periodicity for two months
self.assertEquals(3,
len(simulation_movement_list))
def test_OpenOrder_request_changeSoftwareType(self):
"""
Check that requesting the same instance with a different software type
does not create a new instance
"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + """
LoginERP5TypeTestCase
CallSlaposTriggerBuildAlarm
CleanTic
CallSlaposUpdateDeliveryCausalityStateAlarm
CleanTic
CallVifibSolveAutomaticallyAlarm
CleanTic
CallDeliverSubscriptionSalePackingListAlarm
CleanTic
CallVifibExpandDeliveryLineAlarm
CleanTic
CallDeliverSubscriptionSalePackingListAlarm
CleanTic
CheckSimulationMovement
SlapLogout
LoginERP5TypeTestCase
IncreaseOpenOrderCoverage
Tic
CheckThreeTopLevelSimulationMovement
Logout
LoginTestVifibCustomer
SetSequenceSoftwareInstanceStateDestroyed
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
Tic # in order to update Open Order
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
CheckOpenOrderLineRemoved
Logout
LoginERP5TypeTestCase
Tic # in order to call update simulation alarm of open order
Tic
CheckThreeTopLevelSimulationMovement
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibOpenOrderSimulation))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapAllocationScope(TestVifibSlapWebServiceMixin):
def stepCheckComputerAllocationScopeEmpty(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertEqual(computer.getAllocationScope(), None)
def stepCheckComputerAllocationScopeOpenFriend(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertEqual(computer.getAllocationScope(), 'open/friend')
def stepCheckComputerAllocationScopeClose(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertEqual(computer.getAllocationScope(), 'close')
def stepCheckComputerAllocationScopeOpenPersonal(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertEqual(computer.getAllocationScope(), 'open/personal')
def stepCheckComputerAllocationScopeOpenPublic(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertEqual(computer.getAllocationScope(), 'open/public')
def stepCheckComputerTradeConditionDestinationSectionVifibAdminTestVifibCustomer(
self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
trade_condition = computer.getAggregateRelatedValue(
portal_type='Sale Supply Line').getParentValue()
person_url_list = sorted([q.getRelativeUrl() for q in \
self.portal.portal_catalog(portal_type='Person',
default_email_text=['test_customer@example.org',
'test_computer_vifib_admin@example.org'])])
self.assertEqual(sorted(trade_condition.getDestinationSectionList()),
person_url_list)
request_and_install_software = """
LoginTestVifibCustomer
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
"""
def stepCheckNoRelatedSalePackingListLineForSoftwareInstance(self, sequence,
**kw):
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
self.assertEqual(0, len(software_instance.getAggregateRelatedValueList(
portal_type=self.sale_packing_list_line_portal_type)))
def stepSetSequenceSlaXmlCurrentComputer(self, sequence, **kw):
sequence['sla_xml'] = """<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="computer_guid">%s</parameter>
</instance>""" % sequence['computer_reference']
sequence['requested_filter_dict'] = dict(
computer_guid=sequence['computer_reference'])
def test_allocation_scope_open_personal(self):
"""Check that computer is open/personal it is only available
to owner"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeOpenPersonal
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# fail to instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckNoRelatedSalePackingListLineForSoftwareInstance
Logout
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepComputerSetAllocationScopeOpenFriendTestVifibAdmin(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
request = self.app.REQUEST
self.getPortal().portal_skins.changeSkin("Hosting")
request.set('portal_skin', "Hosting")
computer.Computer_updateAllocationScope(allocation_scope='open/friend',
subject_list=['test_computer_vifib_admin@example.org'])
self.getPortal().portal_skins.changeSkin("View")
request.set('portal_skin', "View")
def test_allocation_scope_open_friend(self):
"""Check that computer is open/friend it is only available
to owner and its friends"""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenFriendTestVifibAdmin
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeOpenFriend
CheckComputerTradeConditionDestinationSectionVifibAdminTestVifibCustomer
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# request as friend
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for friend
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# request as someone else
LoginTestVifibCustomerA
PersonRequestSoftwareInstance
Tic
Logout
# fail to instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckNoRelatedSalePackingListLineForSoftwareInstance
Logout
# request as friend
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for friend
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_open_public(self):
"""Check that computer is open/public it is only available
to anybody"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeOpenPublic
CheckComputerTradeConditionDestinationSectionListEmpty
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_close(self):
"""Check that computer is close it is not only available
to anybody"""
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeClose
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeClose
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# fail to instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckNoRelatedSalePackingListLineForSoftwareInstance
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_empty(self):
"""Check that computer's allocation scope is not set it is unavailable"""
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeEmpty
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeEmpty
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# fail to instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckNoRelatedSalePackingListLineForSoftwareInstance
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
prepare_open_public_computer = TestVifibSlapWebServiceMixin.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeOpenPublic
CheckComputerTradeConditionDestinationSectionListEmpty
Logout
""" + TestVifibSlapWebServiceMixin.prepare_published_software_release \
+ request_and_install_software
def test_allocation_scope_public_software_instance_request(self):
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_open_public_computer + """
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# now this computer patrition request new one
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckSoftwareInstanceAndRelatedComputerPartition
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRequestedComputerPartitionCleanParameterList
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_personal_software_instance_request(self):
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_open_public_computer + """
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# change allocation to personal
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenPersonal
Tic
Logout
LoginDefaultUser
CheckComputerAllocationScopeOpenPersonal
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
# now this computer patrition request new one
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepStoreTestVifibAdminComputerPartitionCoordinate(self, sequence, **kw):
sequence.edit(
test_vifib_admin_computer_reference=sequence['computer_reference'],
test_vifib_admin_computer_partition_reference=sequence[
'computer_partition_reference'],
test_vifib_admin_software_instance_reference=sequence[
'software_instance_reference'],
test_vifib_admin_software_instance_uid=sequence[
'software_instance_uid'],
)
def stepRestoreTestVifibAdminComputerPartitionCoordinate(self,
sequence, **kw):
sequence.edit(
computer_reference=sequence['test_vifib_admin_computer_reference'],
computer_partition_reference=sequence[
'test_vifib_admin_computer_partition_reference'],
software_instance_reference=sequence[
'test_vifib_admin_software_instance_reference'],
software_instance_uid=sequence[
'test_vifib_admin_software_instance_uid'],
)
def test_allocation_scope_friend_software_instance_request(self):
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_open_public_computer + """
# request as friend
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for friend
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
StoreTestVifibAdminComputerPartitionCoordinate
""" + self.stabilise_accounting + """
# request as someone else
LoginTestVifibCustomerA
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# change allocation to friend
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenFriendTestVifibAdmin
Tic
Logout
LoginDefaultUser
CheckComputerAllocationScopeOpenFriend
CheckComputerTradeConditionDestinationSectionVifibAdminTestVifibCustomer
Logout
# now this computer patrition request new one
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
SlapLogout
# now vifib_admin computer partition request new one and suceeds
RestoreTestVifibAdminComputerPartitionCoordinate
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckSoftwareInstanceAndRelatedComputerPartition
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRequestedComputerPartitionCleanParameterList
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_close_software_instance_request(self):
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_open_public_computer + """
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# change allocation to close
LoginTestVifibCustomer
ComputerSetAllocationScopeClose
Tic
Logout
LoginDefaultUser
CheckComputerAllocationScopeClose
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
# now this computer patrition request new one
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_allocation_scope_empty_software_instance_request(self):
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_open_public_computer + """
# request as someone else
LoginTestVifibAdmin
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# change allocation to empty
LoginTestVifibCustomer
ComputerSetAllocationScopeEmpty
Tic
Logout
LoginDefaultUser
CheckComputerAllocationScopeEmpty
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
# now this computer patrition request new one
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_start_computer_partition_allocation_scope_close(self):
"""Check that it is possible to request stop of computer partition even
if computer is close"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + """
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
Logout
LoginDefaultUser
SetComputerCoordinatesFromComputerTitle
CleanTic
Logout
LoginTestVifibCustomer
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SetSequenceSlaXmlCurrentComputer
SetSequenceSoftwareInstanceStateStopped
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginDefaultUser
CheckComputerAllocationScopeOpenPublic
CheckComputerTradeConditionDestinationSectionListEmpty
Logout
""" + self.prepare_published_software_release + \
self.request_and_install_software + """
# request as owner
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for owner
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# request as someone else
LoginTestVifibAdmin
SetSoftwareTitleRandom
PersonRequestSoftwareInstance
Tic
Logout
# instantiate for someone else
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# confirm instantiation
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionNoInstanceHostingSalePackingList
Logout
# close allocation scope of computer
LoginTestVifibCustomer
ComputerSetAllocationScopeClose
Tic
Logout
LoginDefaultUser
CheckComputerAllocationScopeClose
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
# request start and check that it worked
LoginTestVifibAdmin
SetSequenceSoftwareInstanceStateStarted
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapAllocationScope))
return suite
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from slapos import slap
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from random import random
class TestVifibSlapBang(TestVifibSlapWebServiceMixin):
bang_message = 'Bang message'
# expected scenarios
def stepFinishSoftwareInstanceTree(self, sequence, **kw):
rand = str(random())
S1 = 'S1' + rand
S2 = 'S2' + rand
S3 = 'S3' + rand
S4 = 'S4' + rand
root_software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
common_kw = dict(
software_release=sequence['software_release_uri'],
software_type='any', instance_xml=self.minimal_correct_xml,
shared=False,
sla_xml=self.minimal_correct_xml, state='stopped')
root_software_instance.requestInstance(software_title=S1,
**common_kw)
self.stepTic()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
S1_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S1)
S1_instance.requestInstance(software_title=S2, **common_kw)
self.stepTic()
S1_instance.requestInstance(software_title=S3, **common_kw)
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
root_software_instance.requestInstance(software_title=S4,
**common_kw)
self.stepTic()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
S2_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S2)
S3_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S3)
S4_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S4)
self.stepTic()
sequence.edit(
S0_uid = sequence['software_instance_uid'],
S1_uid = S1_instance.getUid(),
S2_uid = S2_instance.getUid(),
S3_uid = S3_instance.getUid(),
S4_uid = S4_instance.getUid()
)
def stepBang(self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
slap_computer_partition.bang(self.bang_message)
sequence.edit(expected_bang_count=sequence.get('expected_bang_count', 2) + 1)
def stepSetCurrentSoftwareInstanceS1(self, sequence, **kw):
S1 = self.portal.portal_catalog.getResultValue(uid=sequence['S1_uid'])
sequence.edit(
software_instance_reference=S1.getReference(),
computer_partition_reference=S1.getAggregateRelatedValue()\
.getAggregateValue(portal_type='Computer Partition').getReference()
)
def stepSetCurrentSoftwareInstanceS3(self, sequence, **kw):
S3 = self.portal.portal_catalog.getResultValue(uid=sequence['S3_uid'])
sequence.edit(
software_instance_reference=S3.getReference(),
computer_partition_reference=S3.getAggregateRelatedValue()\
.getAggregateValue(portal_type='Computer Partition').getReference()
)
def checkSoftwareInstanceBangMessage(self, count, software_instance):
bang_list = [q for q in reversed(software_instance\
.Base_getWorkflowHistoryItemList('instance_slap_interface_workflow'))
if q.action == 'bang']
self.assertEqual(count, len(bang_list))
self.assertEqual(self.bang_message, bang_list[0].comment)
def stepCheckS0BangMessage(self, sequence, **kw):
self.checkSoftwareInstanceBangMessage(
sequence['expected_bang_count'],
self.portal.portal_catalog.getResultValue(uid=sequence['S0_uid']))
def stepCheckS1BangMessage(self, sequence, **kw):
self.checkSoftwareInstanceBangMessage(
sequence['expected_bang_count'],
self.portal.portal_catalog.getResultValue(uid=sequence['S1_uid']))
def stepCheckS2BangMessage(self, sequence, **kw):
self.checkSoftwareInstanceBangMessage(
sequence['expected_bang_count'],
self.portal.portal_catalog.getResultValue(uid=sequence['S1_uid']))
def stepCheckS3BangMessage(self, sequence, **kw):
self.checkSoftwareInstanceBangMessage(
sequence['expected_bang_count'],
self.portal.portal_catalog.getResultValue(uid=sequence['S3_uid']))
def stepCheckS4BangMessage(self, sequence, **kw):
self.checkSoftwareInstanceBangMessage(
sequence['expected_bang_count'],
self.portal.portal_catalog.getResultValue(uid=sequence['S3_uid']))
def test_bang_computer_partition_complex_tree(self):
"""Checks that bangs works on complex tree
For tree like:
S0
/ \
S4 S1
/ \
S2 S3
Invoking bang on Root, S1 or S3 will made whole tree updatable.
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
LoginDefaultUser
FinishSoftwareInstanceTree
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentSoftwareInstance
Bang
Tic
SlapLogout
LoginDefaultUser
CheckS0BangMessage
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginDefaultUser
SetCurrentSoftwareInstanceS1
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentSoftwareInstance
Bang
Tic
SlapLogout
LoginDefaultUser
CheckS1BangMessage
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginDefaultUser
SetCurrentSoftwareInstanceS3
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentSoftwareInstance
Bang
Tic
SlapLogout
LoginDefaultUser
CheckS3BangMessage
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepComputerBang(self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer = self.slap.registerComputer(
sequence['computer_reference'])
slap_computer.bang(self.bang_message)
sequence.edit(expected_bang_count=sequence.get('expected_bang_count', 2) + 5)
def stepCheckComputerBangMessage(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
bang_list = [q for q in computer.Base_getWorkflowHistoryItemList(
'computer_slap_interface_workflow') if q.action == 'report_computer_bang']
self.assertEqual(1, len(bang_list))
self.assertEqual(self.bang_message, bang_list[0].comment)
def test_bang_computer_complex_tree(self):
"""Checks that bangs works on complex tree
For tree like:
S0
/ \
S4 S1
/ \
S2 S3
Invoking bang on Computer will made whole tree updatable.
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
LoginDefaultUser
FinishSoftwareInstanceTree
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
LoginDefaultUser
CheckComputerBangMessage
CheckS0BangMessage
CheckS1BangMessage
CheckS2BangMessage
CheckS3BangMessage
CheckS4BangMessage
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bang_computer_simple_tree(self):
"""Checks that bangs works on simple tree"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Computer owner cannot do bang yet')
def test_admin_bang_computer_complex_tree(self):
"""Checks that bangs works on complex tree
For tree like:
S0
/ \
S4 S1
/ \
S2 S3
Invoking bang on Computer will made whole tree updatable.
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
LoginDefaultUser
FinishSoftwareInstanceTree
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginTestVifibCustomer
ComputerBang
Tic
SlapLogout
LoginDefaultUser
CheckComputerBangMessage
CheckS0BangMessage
CheckS1BangMessage
CheckS2BangMessage
CheckS3BangMessage
CheckS4BangMessage
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepStoreComputerCoordinatesAsC1(self, sequence, **kw):
sequence.edit(
computer_uid_c1=sequence['computer_uid'],
computer_reference_c1=sequence['computer_reference'],
)
def stepRestoreComputerC1Coordinates(self, sequence, **kw):
sequence.edit(
computer_uid=sequence['computer_uid_c1'],
computer_reference=sequence['computer_reference_c1'],
)
def stepStoreComputerCoordinatesAsC0(self, sequence, **kw):
sequence.edit(
computer_uid_c0=sequence['computer_uid'],
computer_reference_c0=sequence['computer_reference'],
)
def stepFinishSoftwareInstanceSpannedTree(self, sequence, **kw):
self.stepLoginDefaultUser()
rand = str(random())
S1 = 'S1' + rand
S2 = 'S2' + rand
S3 = 'S3' + rand
root_software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
common_kw = dict(
software_release=sequence['software_release_uri'],
software_type='any', instance_xml=self.minimal_correct_xml,
shared=False,
state='stopped')
self.logout()
self.login(sequence['software_instance_reference'])
root_software_instance.requestInstance(
software_title=S1,
sla_xml="""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="computer_guid">%s</parameter>
</instance>""" % sequence['computer_reference_c1'],
**common_kw)
self.stepTic()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
S1_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S1)
S1_reference = S1_instance.getReference()
self.logout()
self.login(S1_reference)
S1_instance.requestInstance(
software_title=S2,
sla_xml="""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="computer_guid">%s</parameter>
</instance>""" % sequence['computer_reference_c0'],
**common_kw)
self.stepTic()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
S2_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S2)
S2_reference = S2_instance.getReference()
self.logout()
self.login(S2_reference)
S2_instance.requestInstance(
software_title=S3,
sla_xml="""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="computer_guid">%s</parameter>
</instance>""" % sequence['computer_reference_c1'],
**common_kw)
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
S3_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S3)
S3_reference = S3_instance.getReference()
self.logout()
self.login(S1_reference)
self.stepTic()
self.logout()
self.login(S2_reference)
self.stepTic()
self.logout()
self.login(S3_reference)
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
sequence.edit(
S0_uid = sequence['software_instance_uid'],
S1_uid = S1_instance.getUid(),
S2_uid = S2_instance.getUid(),
S3_uid = S3_instance.getUid(),
)
self.logout()
def test_computer_bang_tree_with_other_computer(self):
"""Check that bang works on complex tree spanned on many computers
For tree like this:
S0 (on non public C0)
\
S1 (on non public C1)
\
S2 (on non public C0)
Bang shall work from all instances.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
"""
# prepare first computer
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibCustomer
SetComputerCoordinatesFromComputerTitle
StoreComputerCoordinatesAsC1
ComputerSetAllocationScopeOpenPersonal
Tic
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# prepare second computer
SlapLoginTestVifibCustomer
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibCustomer
SetComputerCoordinatesFromComputerTitle
StoreComputerCoordinatesAsC0
ComputerSetAllocationScopeOpenPersonal
Tic
CheckComputerTradeConditionDestinationSectionTestVifibCustomer
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Request S0
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
SlapLoginCurrentComputer
SoftwareInstanceBuilding
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
LoginTestVifibCustomer
SetSequenceSoftwareInstanceStateStarted
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
FinishSoftwareInstanceSpannedTree
Tic
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
RestoreComputerC1Coordinates
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_computer_bang_not_called_on_destroying_destroyed(self):
"""Check that bang is ignoring destruction in progress and
destroyed computer partitions"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = self.prepare_destroy_requested_computer_partition + \
"""
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepFinishSoftwareInstancePartlyDestroyedTree(self, sequence, **kw):
self.stepLoginDefaultUser()
rand = str(random())
S1 = 'S1' + rand
root_software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
common_kw = dict(
software_release=sequence['software_release_uri'],
software_type='any', instance_xml=self.minimal_correct_xml,
shared=False,
sla_xml=self.minimal_correct_xml, state='stopped')
self.logout()
self.login(sequence['software_instance_reference'])
root_software_instance.requestInstance(
software_title=S1,
**common_kw)
self.stepTic()
self.stepCallSlaposAllocateInstanceAlarm()
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
S1_instance = self.portal.portal_catalog.getResultValue(
portal_type='Software Instance', title=S1)
S1_reference = S1_instance.getReference()
self.logout()
self.login(S1_reference)
self.logout()
self.login(sequence['software_instance_reference'])
root_software_instance.requestDestroy(
software_release=root_software_instance.getUrlString(),
instance_xml=root_software_instance.getTextContent(),
software_type=root_software_instance.getSourceReference(),
sla_xml=root_software_instance.getSlaXml(),
shared=root_software_instance.getPortalType() == 'Slave Instance',
)
self.stepTic()
self.logout()
self.login(sequence['computer_reference'])
self.portal.portal_slap.destroyedComputerPartition(
sequence['computer_reference'],
root_software_instance.getAggregateValue(
portal_type='Computer Partition').getReference())
self.stepTic()
self.logout()
self.stepLoginDefaultUser()
sequence.edit(
S0_uid = sequence['software_instance_uid'],
S1_uid = S1_instance.getUid(),
)
self.logout()
def test_computer_bang_not_called_on_partly_destroyed_tree(self):
"""Check that bang is ignoring partitions on partly destroyed tree"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
FinishSoftwareInstancePartlyDestroyedTree
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
ComputerBang
Tic
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckTreeLooksLikeRenameComplexTree(self, sequence, **kw):
hosting_subscription_uid = sequence['hosting_subscription_uid']
hosting_subscription = self.portal.portal_catalog.getResultValue(
uid=hosting_subscription_uid
)
root_software_instance = hosting_subscription.portal_catalog.getResultValue(
title=hosting_subscription.getTitle(), portal_type="Software Instance",
root_uid=hosting_subscription_uid)
self.failIfEqual(root_software_instance, None)
children_titles = set([si.getTitle()
for si in root_software_instance.getPredecessorValueList()])
self.failUnless(set(['children_a', 'children_b']) <= children_titles)
children_b_child = hosting_subscription.portal_catalog.getResultValue(
title='children_b_child',
root_uid=hosting_subscription.getUid(),
)
self.failIfEqual(children_b_child, None)
@skip('Ignored for now')
def test_ComputerPartition_rename_root_and_bang(self):
r"""
Request Master: __________
/ \
| HS: Master |
\__________/
_____|____
/ \
| SI: Master |
\__________/
Rename Software Instance Master into MasterDead:
__________
/ \
| HS: Master |
\__________/
_______|______
/ \
| SI: MasterDead |
\______________/
Banging the tree should result:
_____________________________
/ \
| HS: Master |
\______________________________/
____/_____ _______\______
/ \ / \
| SI: Master | | SI: MasterDead |
\__________/ \______________/
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
SetRootSoftwareInstanceCurrentInstance
Tic
LoginDefaultUser
RenameCurrentSoftwareInstanceDead
Tic
Logout
SlapLoginCurrentSoftwareInstance
Bang
CallSlaposAllocateInstanceAlarm
SlapLogout
Tic
LoginTestVifibCustomer
CheckTreeHasARootSoftwareInstance
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Ignored for now')
def test_ComputerPartition_rename_root_complex_tree(self):
r"""
Request Master which is a software realease having a complex tree :
___________________________
/ \
| HS: Master |
\____________________________/
_____________|_____________
/ \
| SI: Master |
\____________________________/
_____/_____ _____\_____
/ \ / \
| SI: Child A | | SI: Child B |
\___________/ \___________/
______|______
/ \
| SI: GrandChild |
\______________/
Rename Software Instance Master :
___________________________
/ \
| SI: Master |
\____________________________/
_____________|_____________
/ \
| SI: MasterDead |
\____________________________/
_____/_____ _____\_____
/ \ / \
| SI: Child A | | SI: Child B |
\___________/ \___________/
______|______
/ \
| SI: GrandChild |
\______________/
Run bang() on the tree. We expect to have a new root as :
_______________________________________________
/ \
| HS: Master |
\_______________________________________________/
_____________|______________ _______|______
/ \ / \
| SI: Master | | SI: MasterDead |
\____________________________/ \______________/
_____/_____ _____\_____
/ \ / \
| SI: Child A | | SI: Child B |
\___________/ \___________/
______|______
/ \
| SI: GrandChild |
\______________/
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
LoginDefaultUser
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SlapLoginTestVifibCustomer
SetSoftwareInstanceRoot
RenameCurrentSoftwareInstanceDead
Tic
Bang
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLogout
LoginDefaultUser
SetSoftwareInstanceGetRootOfTheTree
SetRootSoftwareInstanceCurrentInstance
SelectRequestedReferenceChildrenA
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SelectRequestedReferenceChildrenB
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SlapLoginCurrentComputer
CheckTreeHasARootSoftwareInstance
CheckTreeLooksLikeRenameComplexTree
SlapLogout
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_rename_child_complex_tree(self):
r"""
Request A which is a software realease having a complex tree :
___________________________
/ \
| HS: Master |
\____________________________/
_____________|_____________
/ \
| SI: Master |
\____________________________/
_____/_____ _____\_____
/ \ / \
| SI: Child A | | SI: Child B |
\___________/ \___________/
______|______
/ \
| SI: GrandChild |
\______________/
Rename child C into E :
(Rename reattach to root as Luke wanted it)
________________________________
/ \
| HS: Master |
\________________________________/
________________|_______________
/ \
| SI: Master |
\________________________________/
_____/_____ _________\______
/ \ / \
| SI: Child A | | SI: Child B Dead |
\___________/ \________________/
______|______
/ \
| SI: GrandChild |
\______________/
Bang the tree. We espect to have a new C replacing it,
as : _________________________________________________
/ \
| HS: Master |
\_________________________________________________/
_____________|___________________________________
/ \
| SI: Master |
\_________________________________________________/
_____/_____ _____\_____ _______|________
/ \ / \ / \
| SI: Child A | | SI: Child B | | SI: Child B Dead |
\___________/ \___________/ \________________/
______|______
/ \
| SI: GrandChild |
\______________/
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
LoginDefaultUser
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SlapLoginTestVifibCustomer
SetSoftwareInstanceChildrenB
RenameCurrentSoftwareInstanceDead
Tic
Bang
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLogout
LoginDefaultUser
SetSoftwareInstanceGetRootOfTheTree
SetRootSoftwareInstanceCurrentInstance
SelectRequestedReferenceChildrenA
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SelectRequestedReferenceChildrenB
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginDefaultUser
SlapLoginCurrentComputer
CheckTreeHasARootSoftwareInstance
CheckTreeLooksLikeRenameComplexTree
SlapLogout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapBang))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
import random
import transaction
from Products.ERP5Type.tests.backportUnittest import skip
class TestVifibSlapBug(TestVifibSlapWebServiceMixin):
def test_bug_Person_request_more_then_one_instance(self):
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_person_requested_software_instance + '\
LoginTestVifibCustomer \
PersonRequestSoftwareInstance \
Tic \
Logout \
CallSlaposAllocateInstanceAlarm \
CleanTic \
CallSlaposTriggerBuildAlarm \
CleanTic \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_ComputerPartition_request_two_similar(self):
"""
Checks that requesting twice with different arguments from same Computer
Partition will return different objects."""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestTwoAndCheckDifferentResult \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_doubleClickOnStart(self):
sequence_list = SequenceList()
sequence_string = self\
.prepare_stopped_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceStart
RequestSoftwareInstanceStart
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_doubleClickOnDestroy(self):
sequence_list = SequenceList()
sequence_string = self\
.prepare_installed_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
RequestSoftwareInstanceDestroyRaisesUnsupportedWorkflowMethod
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepArchiveSoftwareRelease(self, sequence, **kw):
"""
Submit the software release document.
"""
software_release_uid = sequence["software_release_uid"]
software_release = self.portal.portal_catalog.getResultValue(
uid=software_release_uid)
software_release.portal_workflow.doActionFor(software_release,
'archive_action')
def test_bug_archived_software_release_access(self):
"""Checks that Computer has access to archived Software Release"""
sequence_string = self.\
prepare_start_requested_computer_partition_sequence_string + \
"""
LoginTestVifibDeveloper
ArchiveSoftwareRelease
Tic
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list = SequenceList()
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepStoreCurrentSoftwareInstanceUidBufferA(self, sequence, **kw):
sequence['buffer_a_software_instance_uid'] = sequence['software_instance_uid']
def stepStoreCurrentSoftwareInstanceUidBufferB(self, sequence, **kw):
sequence['buffer_b_software_instance_uid'] = sequence['software_instance_uid']
def stepStoreCurrentComputerUidBufferA(self, sequence, **kw):
sequence['buffer_a_computer_uid'] = sequence['computer_uid']
def stepStoreCurrentComputerUidBufferB(self, sequence, **kw):
sequence['buffer_b_computer_uid'] = sequence['computer_uid']
def stepRestoreSoftwareInstanceUidFromBufferA(self, sequence, **kw):
sequence['software_instance_uid'] = sequence['buffer_a_software_instance_uid']
def stepRestoreComputerUidFromBufferA(self, sequence, **kw):
sequence['computer_uid'] = sequence['buffer_a_computer_uid']
def stepRestoreComputerUidFromBufferB(self, sequence, **kw):
sequence['computer_uid'] = sequence['buffer_b_computer_uid']
def stepStoreCurrentComputerReferenceBufferA(self, sequence, **kw):
sequence['buffer_a_computer_reference'] = sequence['computer_reference']
def stepStoreCurrentComputerReferenceBufferB(self, sequence, **kw):
sequence['buffer_b_computer_reference'] = sequence['computer_reference']
def stepStoreCurrentComputerPartitionUidBufferA(self, sequence, **kw):
sequence['buffer_a_computer_partition_uid'] = sequence['computer_partition_uid']
def stepStoreCurrentComputerPartitionUidBufferB(self, sequence, **kw):
sequence['buffer_b_computer_partition_uid'] = sequence['computer_partition_uid']
def stepStoreCurrentComputerPartitionReferenceBufferA(self, sequence, **kw):
sequence['buffer_a_computer_partition_reference'] = sequence['computer_partition_reference']
def stepStoreCurrentComputerPartitionReferenceBufferB(self, sequence, **kw):
sequence['buffer_b_computer_partition_reference'] = sequence['computer_partition_reference']
def stepRestoreComputerReferenceFromBufferA(self, sequence, **kw):
sequence['computer_reference'] = sequence['buffer_a_computer_reference']
def stepRestoreComputerReferenceFromBufferB(self, sequence, **kw):
sequence['computer_reference'] = sequence['buffer_b_computer_reference']
def stepRestoreComputerPartitionUidFromBufferA(self, sequence, **kw):
sequence['computer_partition_uid'] = sequence['buffer_a_computer_partition_uid']
def stepRestoreComputerPartitionReferenceFromBufferA(self, sequence, **kw):
sequence['computer_partition_reference'] = sequence['buffer_a_computer_partition_reference']
def stepCheckHostingSubscriptionMultipleComputerAuditor(self, sequence, **kw):
hosting_subscription = self.portal.portal_catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
role_list = hosting_subscription.get_local_roles()
setup_packing_list_line_list = [q for q in
hosting_subscription.getAggregateRelatedValueList(
portal_type='Sale Packing List Line') if q.getResource() ==
self.portal.portal_preferences.getPreferredInstanceSetupResource()]
computer_list = [q.getAggregateValue(
portal_type='Computer Partition').getParentValue() for q in
setup_packing_list_line_list]
for computer in computer_list:
self.assertTrue((computer.getReference(), ('Auditor',))) in role_list
def test_bug_destruction_of_partition_originated_from_another_computer(self):
"""Checks that computer is capable to destroy own Software Instance
If software instance originated on computer comes from another computer it
shall be possible to sucesfully destroy it.
Test is done in a way to trigger unstable Assignor role calculation
on Hosting Subscription which leads to unavailability of Software Instances
from one computer to another.
"""
sequence_list = SequenceList()
sequence_string = """
# Prepare software release shared by both Computers
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create first computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install software on first computer
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Now request and instantiate this software release on first computer
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
StoreCurrentComputerPartitionReferenceBufferA
StoreCurrentComputerPartitionUidBufferA
StoreCurrentSoftwareInstanceUidBufferA
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# Start it..
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
# ...stop it...
LoginDefaultUser
RequestSoftwareInstanceStop
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
# ...and request destruction
LoginDefaultUser
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListDelivered
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# Now prepare second computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferB
StoreCurrentComputerUidBufferB
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
StoreCurrentComputerReferenceBufferB
StoreCurrentComputerUidBufferB
# Now request self software release from one computer to another
RestoreComputerReferenceFromBufferA
RestoreComputerUidFromBufferA
RestoreSoftwareInstanceUidFromBufferA
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
StoreCurrentComputerPartitionReferenceBufferB
StoreCurrentComputerPartitionUidBufferB
StoreCurrentSoftwareInstanceUidBufferB
RestoreComputerReferenceFromBufferB
RestoreComputerUidFromBufferB
# Start the requested software instance...
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
Logout
# ...and stop it
LoginDefaultUser
RequestSoftwareInstanceStop
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
# Now request destruction of second software instance...
LoginDefaultUser
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListDelivered
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# ...and destroy it
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
# Time to switch back to first software instance and destroy it
RestoreComputerPartitionReferenceFromBufferA
RestoreComputerPartitionUidFromBufferA
RestoreSoftwareInstanceUidFromBufferA
RestoreComputerReferenceFromBufferA
RestoreComputerUidFromBufferA
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
LoginDefaultUser
CheckHostingSubscriptionMultipleComputerAuditor
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_destruction_confirmed_instance_setup(self):
"""Proves that all is correctly handled in case of confirmed instance
setup packing list existence"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + \
"""
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# Now there are two packing lists in confirmed state:
# * one for instance setup
# * one for instance destruction
# Simulate typical scenario:
# * stopped
# * commit
# * destroyed
# * commit
# * tic
SlapLoginCurrentComputer
SoftwareInstanceStopped
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
CheckComputerPartitionInstanceHostingSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_destruction_with_unfinished_packing_list(self):
"""Proves that even if some packing lists are not fully delivered
it is possible to destroy software instance"""
sequence_list = SequenceList()
sequence_string = """
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create first computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install software on first computer
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Now request and instantiate this software release on first computer
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# Request destruction...
LoginDefaultUser
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
# ...and destroy it
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepDirectRequestComputerPartitionRaisesDisconnectedSoftwareTree(self,
sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue(
uid = sequence['software_instance_uid'])
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree,
software_instance.requestInstance,
software_release=sequence['software_release_uri'],
software_type=sequence['requested_reference'],
software_title=sequence['requested_reference'],
shared=False,
instance_xml=self.minimal_correct_xml,
sla_xml=self.minimal_correct_xml,
state='started'
)
transaction.abort()
def test_bug_orhpaned_software_instance(self):
"""Check that no orphaned Software Instances would be created
In below scenario system shall behave like mentioned:
OpenOrder.request(SR, A) | SR(A)
A.request(SR, B) | SR(A) <- SR(B)
B.request(SR, C) | SR(A) <- SR(B) <- SR(C)
C.request(SR, B) raises immediately, because the result would be:
SR(A)
SR(B) <- SR(C)
do B would become root of orphaned tree.
"""
# Setup sufficient amount of CP
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = """
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create the computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install the software release
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Create Software Instance A (originates from Open Order)
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# From root request B
SelectRequestedReferenceB
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# From B request C
SelectRequestedReferenceC
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
Tic
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# Try to: from C request B and prove that it raises
SelectRequestedReferenceB
LoginDefaultUser # login as superuser in order to work in erp5
DirectRequestComputerPartitionRaisesDisconnectedSoftwareTree
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepDirectRequestComputerPartitionRaisesCyclicSoftwareTree(self,
sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue(
uid = sequence['software_instance_uid'])
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree,
software_instance.requestInstance,
software_release=sequence['software_release_uri'],
software_type=sequence['requested_reference'],
software_title=sequence['requested_reference'],
shared=False,
instance_xml=self.minimal_correct_xml,
sla_xml=self.minimal_correct_xml,
state='started'
)
transaction.abort()
def test_bug_cyclic_software_instance(self):
"""Check that no cyclic Software Instance trees would be created
In below scenario system shall behave like mentioned:
OpenOrder.request(SR, A) | SR(A)
A.request(SR, B) | SR(A) <- SR(B)
B.request(SR, A) | SR(A) <- SR(B) <- SR(C)
C.request(SR, B) raises immediately, because the result would be:
SR(A)
SR(B) <-> SR(C)
so B and C would be cyclic
"""
# Setup sufficient amount of CP
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = """
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create the computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install the software release
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Create Software Instance A (originates from Open Order)
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# From root request B
SelectRequestedReferenceB
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# From B request C
SelectRequestedReferenceC
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# Try to: from C request B and prove that it raises
SelectRequestedReferenceB
LoginDefaultUser # login as superuser in order to work in erp5
DirectRequestComputerPartitionRaisesCyclicSoftwareTree
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
import erp5.document.SoftwareInstance
def makeTrue(*args, **kwargs):
return True
# Disable temporialy checkConnected in order to have only
# checkCyclic called
erp5.document.SoftwareInstance.original_checkConnected = \
erp5.document.SoftwareInstance.checkConnected
erp5.document.SoftwareInstance.checkConnected = makeTrue
try:
sequence_list.play(self)
finally:
erp5.document.SoftwareInstance.checkConnected = \
erp5.document.SoftwareInstance.original_checkConnected
del(erp5.document.SoftwareInstance.original_checkConnected)
def stepDirectRequestComputerPartitionRaisesValueError(self,
sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue(
uid = sequence['software_instance_uid'])
self.assertRaises(ValueError,
software_instance.requestInstance,
software_release=sequence['software_release_uri'],
software_type=sequence['requested_reference'],
software_title=sequence['requested_reference'],
shared=False,
instance_xml=self.minimal_correct_xml,
sla_xml=self.minimal_correct_xml,
state='started'
)
def test_bug_cyclic_software_instance_small_tree(self):
"""Check that no cyclic Software Instance trees would be created
In below scenario system shall behave like mentioned:
OpenOrder.request(SR, A) | SR(A)
A.request(SR, B) | SR(A) <- SR(B)
B.request(SR, A) raises immediately, because the result would be:
SR(A) <-> SR(B)
so B and A would be cyclic
"""
# Setup sufficient amount of CP
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = """
# Prepare software release
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
# Create the computer
SlapLoginTestVifibAdmin
CustomerRegisterNewComputer
Tic
SlapLogout
LoginTestVifibAdmin
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPublic
Tic
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
StoreCurrentComputerReferenceBufferA
StoreCurrentComputerUidBufferA
# Install the software release
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
# Create Software Instance A (originates from Open Order)
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
# From root request B
SelectRequestedReferenceB
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
CheckSoftwareInstanceAndRelatedComputerPartitionNoPackingListCheck
CheckRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
LoginDefaultUser
SetCurrentSoftwareInstanceRequested
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
Logout
# Try to: From B request root
SelectRequestedReferenceRootSoftwareInstanceTitle
LoginDefaultUser # login as superuser in order to work in erp5
DirectRequestComputerPartitionRaisesValueError
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetRequestedStateStarted(self, sequence, **kw):
sequence['requested_state'] = 'started'
def stepSetRequestedStateStopped(self, sequence, **kw):
sequence['requested_state'] = 'stopped'
def stepSetRequestedReferenceRandom(self, sequence, **kw):
sequence['requested_reference'] = str(random.random())
def test_request_start_non_instantiated_partition(self):
"""Prove that requesting start of non instantiated partition will not
result in any error"""
self.computer_partition_amount = 0
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SlapLoginTestVifibCustomer
SetRequestedStateStarted
SetRequestedReferenceRandom
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
SoftwareInstanceFailedAllocation
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SoftwareInstanceFailedAllocation
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetSequenceSoftwareInstanceRequestedStateDestroyed(self, sequence, **kw):
sequence['requested_state'] = 'destroyed'
def test_request_new_with_destroyed_while_looking_for_partition_reference(self):
"""Prove that having destroyed SI allows to request new one with same
reference, when destruction was done while looking for new partition"""
self.computer_partition_amount = 0
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReferenceAndTitle
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckSoftwareInstanceNoDeliveryRelated
Logout
LoginTestVifibCustomer
SetSequenceSoftwareInstanceStateDestroyed
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CheckSoftwareInstanceCancelledSaleOrderLine
Tic # in order to give chance to update Open Order
CheckOpenOrderLineRemoved
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckSoftwareInstanceOrderedSaleOrderLine
CheckSoftwareInstanceNoDeliveryRelated
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Unsupported by the cache on slaptool')
def test_request_new_with_destroyed_reference(self):
"""Prove that having destroyed SI allows to request new one with same
reference"""
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
SetRequestedStateStopped
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckPersonRequestedSoftwareInstanceAndRelatedComputerPartition
SetSelectedComputerPartition
SetRequestedComputerPartition
CheckComputerPartitionNoInstanceHostingSalePackingList
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckPersonRequestedSoftwareInstanceAndRelatedComputerPartition
SetSelectedComputerPartition
SetRequestedComputerPartition
CheckComputerPartitionNoInstanceHostingSalePackingList
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Tic
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_request_new_with_destroyed_reference_web_ui(self):
"""Prove that having destroyed SI allows to request new one with same
reference
Supports web UI case.
"""
sequence_list = SequenceList()
sequence_string = "SetSoftwareTitleRandom" + \
self.prepare_destroyed_computer_partition + \
"""
LoginTestVifibCustomer
SetSequenceSoftwareInstanceStateStopped
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckComputerPartitionInTable(self, sequence, **kw):
self.assertEqual(
1,
self.portal.erp5_sql_connection.manage_test(
'select count(*) from computer_partition where uid=%s' %
sequence['computer_partition_uid'])[0][0]
)
def stepCheckComputerPartitionNotInTable(self, sequence, **kw):
self.assertEqual(
0,
self.portal.erp5_sql_connection.manage_test(
'select count(*) from computer_partition where uid=%s' %
sequence['computer_partition_uid'])[0][0]
)
def test_catalog_after_destruction(self):
"""Test that computer partition if correctly catalogged after destruction"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + \
"""
LoginDefaultUser
CheckComputerPartitionInTable
Logout
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionNotInTable
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInTable
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
Logout
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInTable
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetSoftwareInstanceUidToCurrentSlave(self, sequence, **kw):
computer_partition = self.portal.portal_catalog.getResultValue(uid=sequence[
'computer_partition_uid'])
slave_instance = self.portal.portal_catalog.getResultValue(
portal_type="Slave Instance",
validation_state="validated",
default_aggregate_uid=computer_partition.getUid(),
)
sequence['software_instance_uid'] = slave_instance.getUid()
def test_catalog_slave_destruction(self):
"""Test that computer partition if correctly catalogged with slave destruction"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + \
"""
LoginDefaultUser
CheckComputerPartitionInTable
Logout
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
SoftwareInstanceAvailable
Tic
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInTable
SetSoftwareInstanceUidToCurrentSlave
Logout
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInTable
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepMarkBusyComputerPartition(self, sequence, **kw):
computer_partition = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_partition_uid'])
computer_partition.markBusy()
def stepUpdateLocalRolesOnComputerPartition(self, sequence, **kw):
computer_partition = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_partition_uid'])
computer_partition.updateLocalRolesOnSecurityGroups()
def stepCheckNoHostingSubscriptionComputerPartitionLocalRoles(self, sequence,
**kw):
computer_partition = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_partition_uid'])
hosting_subscription = self.portal.portal_catalog.getResultValue(
uid=sequence['hosting_subscription_uid'])
self.assertTrue(hosting_subscription.getReference() not in \
computer_partition.__ac_local_roles__)
def test_hosting_subscription_security_on_partition_with_destroyed(self):
"""Checks that history of Computer Partition does not impacts its security
configuration"""
sequence_list = SequenceList()
sequence_string = self.prepare_destroyed_computer_partition + \
"""
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListDelivered
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
# Marked busy in order to simulate previous wrong behaviour
MarkBusyComputerPartition
Tic
UpdateLocalRolesOnComputerPartition
Tic
# All related packing lists are delivered, so no local roles for
# Hosting Subscription shall be defined
CheckNoHostingSubscriptionComputerPartitionLocalRoles
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_bug_person_request_ComputerPartition_own_computer(self):
"""Checks that Person using Slap interface is able to request Computer
Partition"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
"""
Logout
RequestCredentialFromWebSite
Tic
LoginDefaultUser
SubmitCredentialRequest
Tic
CallAcceptSubmittedCredentialsAlarm
Tic
Logout
LoginERP5TypeTestCase
CallSlaposTriggerBuildAlarm
Tic
CallStopConfirmedSaleInvoiceTransactionAlarm
Tic
CallSlaposTriggerBuildAlarm
Tic
PayPayment
Tic
Logout
""" + self.stabilise_accounting + """
SlapLoginWebUser
CustomerRegisterNewComputer
Tic
SlapLogout
LoginWebUser
SetComputerCoordinatesFromComputerTitle
ComputerSetAllocationScopeOpenPersonal
Logout
SlapLoginCurrentComputer
FormatComputer
Tic
SlapLogout
LoginWebUser
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginWebUser
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginWebUser
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckPersonRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
SlapLogout
LoginWebUser
CheckViewCurrentSoftwareInstance
CheckWriteCurrentSoftwareInstance
Tic
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapBug))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import transaction
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputer(TestVifibSlapWebServiceMixin):
def stepCheckRequestedComputerCertificate(self, sequence, **kw):
computer = sequence['requested_computer']
sequence['computer_reference'] = computer._computer_id
certificate_dict = computer.generateCertificate()
transaction.commit()
self.assertTrue('certificate' in certificate_dict)
self.assertTrue('key' in certificate_dict)
self.assertNotEqual(None, certificate_dict['certificate'])
self.assertNotEqual(None, certificate_dict['key'])
self.assertTrue(certificate_dict['key'].startswith(
'-----BEGIN PRIVATE KEY-----'))
self.assertTrue('-----BEGIN CERTIFICATE-----' in \
certificate_dict['certificate'])
computer = self.portal.portal_catalog.getResultValue(
reference=sequence['computer_reference'], portal_type='Computer')
self.assertNotEqual(None, computer.getDestinationReference())
sequence['certificate_reference'] = computer.getDestinationReference()
def test_request(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
SetComputerTitle \
RequestComputer \
CleanTic \
CheckRequestedComputerCertificate \
SlapLogout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckDoubleRequestRaisesNotImplementedError(self, sequence, **kw):
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue()
person.requestComputer(computer_title=sequence['computer_title'])
transaction.commit()
self.assertRaises(NotImplementedError, person.requestComputer,
computer_title=sequence['computer_title'])
def test_request_twice_activity(self):
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
SetComputerTitle \
CheckDoubleRequestRaisesNotImplementedError \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckComputerNoCertificate(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
reference=sequence['computer_reference'], portal_type='Computer')
self.assertEqual(None, computer.getDestinationReference())
def test_revokeCertificate(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
SetComputerTitle \
RequestComputer \
CleanTic \
CheckRequestedComputerCertificate \
RevokeComputerCertificate \
CheckComputerNoCertificate \
SlapLogout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckRevokeComputerCertificateRaisesValueError(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
reference=sequence['computer_reference'], portal_type='Computer')
self.assertRaises(ValueError, computer.revokeCertificate)
def test_revokeCertificateRevoked(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
SetComputerTitle \
RequestComputer \
CleanTic \
CheckRequestedComputerCertificate \
RevokeComputerCertificate \
CheckComputerNoCertificate \
SlapLogout \
LoginTestVifibAdmin \
CheckRevokeComputerCertificateRaisesValueError \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_getCertificate(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
SetComputerTitle \
RequestComputer \
CleanTic \
CheckRequestedComputerCertificate \
RevokeComputerCertificate \
CheckComputerNoCertificate \
CleanTic \
CheckRequestedComputerCertificate \
SlapLogout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckGetComputerCertificateRaisesValueError(self, sequence, **kw):
computer = self.portal.portal_catalog.getResultValue(
reference=sequence['computer_reference'], portal_type='Computer')
self.assertRaises(ValueError, computer.generateCertificate)
def test_getCertificateNotRevoked(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
SetComputerTitle \
RequestComputer \
CleanTic \
CheckRequestedComputerCertificate \
SlapLogout \
LoginTestVifibAdmin \
CheckGetComputerCertificateRaisesValueError \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputer))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import skip
import transaction
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerGetComputerPartitionList(TestVifibSlapWebServiceMixin):
########################################
# Computer.getComputerPartitionList
########################################
def test_Computer_getComputerPartitionList_validatedComputer(self):
"""
Check that getComputerPartitionList returns an empty result if the
validated computer is not related to any packing list.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_emptyPartition(self):
"""
Check that getComputerPartitionList returns nothing if Computer Partition
is not related with proper Sale Packing List Line
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_twoEmptyPartition(self):
"""
Check that getComputerPartitionList returns nothing if Computer Partitions
are not related with proper Sale Packing List Lines
"""
self.computer_partition_amount = 2
self.test_Computer_getComputerPartitionList_emptyPartition()
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getComputerPartitionList_unknowComputerUid(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginRandomComputer \
CheckUnauthorizedSlapGetComputerPartitionListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getComputerPartitionList_draftComputer(self):
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout \
\
SlapLoginRandomComputer \
CheckUnauthorizedSlapGetComputerPartitionListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_validatedAndDraftComputer(self):
"""
Check that getComputerPartitionList returns an empty result if there are
one draft and one validated computer.
"""
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout \
' + self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getComputerPartitionList_TwoValidatedComputer(self):
# XXX: It shall be part of VifibMachineAuthentication test suite
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
\
LoginDefaultUser \
DuplicateAndValidateCurrentComputer \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckUnauthorizedSlapGetComputerPartitionListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
try:
sequence_list.play(self)
finally:
self.login('ERP5TypeTestCase')
for c in self.portal.computer_module.contentValues():
if c.getValidationState() == 'validated':
c.invalidate()
transaction.commit()
def test_Computer_getComputerPartitionList_SetupResource_ConfirmedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
confirmed state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_SetupResource_StartedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
started state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_ConfirmedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
confirmed state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_start_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_StartedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
started state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_StartedState_with_slave(self):
"""
Check that calling Computer.getComputerPartitionList works in
started state with the hosting resource when a Slave Partition is present.
We validate checking more them one Slave Instance allocation.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
SetSoftwareTitleRandom \
PersonRequestSlaveInstance \
Tic \
SlapLogout \
\
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceAvailable \
Tic \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
SetSoftwareTitleRandom \
PersonRequestSlaveInstance \
Tic \
SlapLogout \
\
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
\
LoginTestVifibCustomer \
RequestSoftwareInstanceStop \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceHostingSalePackingListStopped \
Logout \
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_StoppedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
stopped state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stop_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginTestVifibCustomer \
SetSequenceSoftwareInstanceStateDestroyed \
PersonRequestSoftwareInstance \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceDestroyed \
Tic \
Tic \
SlapLogout \
LoginDefaultUser \
CheckComputerPartitionInstanceCleanupSalePackingListDelivered \
CheckComputerPartitionIsFree \
CheckOpenOrderLineRemoved \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_HostingResource_DeliveredState(self):
"""
Check that calling Computer.getComputerPartitionList works in
delivered state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_CleanupResource_ConfirmedState(self):
"""
Check that calling Computer.getComputerPartitionList works in
confirmed state with the cleanup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_destroy_requested_computer_partition + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_CleanupResource_DeliveredState(self):
"""
Check that calling Computer.getComputerPartitionList works in
delivered state with the cleanup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_destroyed_computer_partition + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getComputerPartitionList_twoSalePackingList(self):
"""
Check that calling Computer.getComputerPartitionList uses the latest sale packing
list for calculation
"""
sequence_list = SequenceList()
sequence_string = self.prepare_start_requested_computer_partition_sequence_string + '\
LoginDefaultUser \
SetHostingAfterSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
Tic \
LoginDefaultUser \
CheckSalePackingListNoErrorText \
SetHostingBeforeSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepDamageSoftwareInstanceConnectionXml(self, sequence, **kw):
instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
instance.edit(connection_xml="""
DAMAGED<BAD?xml XMLversion="1.0" encoding="utf-8"?>""")
def stepCheckDamageSoftwareInstanceSiteConsistency(self, sequence, **kw):
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
self.portal.portal_alarms.vifib_check_consistency.activeSense()
transaction.commit()
self.tic()
consistency_error_list = self.portal.portal_alarms.vifib_check_consistency\
.Alarm_getConsistencyCheckReportLineList()
self.assertEqual(1, len(consistency_error_list))
consistency_error = consistency_error_list[0]
self.assertEqual(consistency_error.getObject().getPath(),
software_instance.getPath())
self.assertTrue('Connection XML is invalid' in str(consistency_error.getMessage()))
self.assertTrue(self.portal.portal_alarms.vifib_check_consistency.sense())
self.checkDivergency()
def test_Computer_getComputerPartitionList_damaged_xml(self):
"""Check that getComputerPartitionList works in case of trying to damag XML,
which is refused."""
sequence_list = SequenceList()
sequence_string = self\
.prepare_install_requested_computer_partition_sequence_string + """
LoginDefaultUser
SetSoftwareInstanceValidXML
DamageSoftwareInstanceConnectionXml
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
Tic
SlapLogout
LoginERP5TypeTestCase
CheckDamageSoftwareInstanceSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerGetComputerPartitionList))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import skip
import transaction
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerGetSoftwareReleaseList(TestVifibSlapWebServiceMixin):
########################################
# Computer.getSoftwareReleaseList
########################################
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getSoftwareReleaseList_unknowComputerUid(self):
sequence_list = SequenceList()
sequence_string = '\
SlapLoginRandomComputer \
CheckUnauthorizedComputerGetSoftwareReleaseListCall \
Tic \
SlapLogout \
CheckUnexistingComputer \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getSoftwareReleaseList_draftComputer(self):
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckUnauthorizedComputerGetSoftwareReleaseListCall \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getSoftwareReleaseList_validatedComputer(self):
"""
Check that getSoftwareReleaseList returns an empty result if the
validated computer is not related to any packing list.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckEmptyComputerGetSoftwareReleaseListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Computer_getSoftwareReleaseList_validatedAndDraftComputer(self):
"""
Check that getSoftwareReleaseList returns an empty result if there are
one draft and one validated computer.
"""
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout '\
+ self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckEmptyComputerGetSoftwareReleaseListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_Computer_getSoftwareReleaseList_TwoValidatedComputer(self):
# XXX: It shall be part of VifibMachineAuthentication test suite
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
LoginDefaultUser \
DuplicateAndValidateCurrentComputer \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckUnauthorizedComputerGetSoftwareReleaseListCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
try:
sequence_list.play(self)
finally:
self.login('ERP5TypeTestCase')
for c in self.portal.computer_module.contentValues():
if c.getValidationState() == 'validated':
c.invalidate()
transaction.commit()
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerGetSoftwareReleaseList))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
class TestVifibSlapComputerGetStatus(TestVifibSlapWebServiceMixin):
########################################
# Computer.getStatus
########################################
def stepCheckNoDataComputerGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer = self.slap.registerComputer(
computer_guid)
status = computer.getStatus()
self.assertEquals('SlapOS Master', status['user'])
self.assertEquals('#error no data found for %s' % \
sequence["computer_reference"], status['text'])
def test_Computer_getStatus_noComputer(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckNoDataComputerGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckOKComputerGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer = self.slap.registerComputer(
computer_guid)
status = computer.getStatus()
self.assertEquals(sequence['computer_reference'], status['user'])
self.assertEquals('#access %s' % sequence["computer_reference"],
status['text'])
def test_Computer_OK_getStatus(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginCurrentComputer \
CheckSuccessComputerGetComputerPartitionCall \
CheckOKComputerGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckErrorComputerGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer = self.slap.registerComputer(
computer_guid)
status = computer.getStatus()
self.assertEquals(sequence['computer_reference'], status['user'])
self.assertEquals('#error bang', status['text'])
def stepSoftwareReleaseError(self, sequence,
**kw):
"""
"""
url = sequence["software_release_uri"]
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
software_release = self.slap.registerSoftwareRelease(url)
software_release.error("ErrorLog")
def stepComputerBang(self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer = self.slap.registerComputer(
sequence['computer_reference'])
slap_computer.bang('foo')
def test_Computer_Error_getStatus(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
ComputerBang \
CheckErrorComputerGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerGetStatus))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionAvailable(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.available
########################################
def test_ComputerPartition_available_afterRegister(self):
"""
Check that calling ComputerPartition.available after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + """
SlapLoginCurrentComputer
CheckNotFoundComputerPartitionAvailableAfterRegisterCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_available_successConfirmed(self):
"""
Check that calling ComputerPartition.available change the sale packing
list state to stopped.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + """
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_available_alreadyStartedSalePackingList(self):
"""
Check that calling ComputerPartition.available more then once can be called
without error and changes nothing
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + """
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionAvailable))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionBuilding(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.building
########################################
def test_ComputerPartition_building_afterRegister(self):
"""
Check that calling ComputerPartition.building after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckNotFoundComputerPartitionBuildingAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_building_success(self):
"""
Check that calling ComputerPartition.building change the sale packing
list state to started.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + """
LoginTestVifibCustomer
SetSequenceSoftwareInstanceStateDestroyed
PersonRequestSoftwareInstance
Tic
Logout
SlapLoginCurrentComputer
SoftwareInstanceDestroyed
Tic
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListDelivered
CheckComputerPartitionIsFree
CheckOpenOrderLineRemoved
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_building_alreadyConfirmedSalePackingList(self):
"""
Check that calling ComputerPartition.building failed if there is already
confirmed sale packing list
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + """
SlapLoginCurrentComputer
SoftwareInstanceBuilding
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionBuilding))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionConnection(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.getConnectionParameter
# ComputerPartition.setConnectionDict
########################################
def test_ComputerPartition_Connection(self):
sequence_list = SequenceList()
sequence_string = """
LoginTestVifibDeveloper
SelectNewSoftwareReleaseUri
CreateSoftwareRelease
Tic
SubmitSoftwareRelease
Tic
CreateSoftwareProduct
Tic
ValidateSoftwareProduct
Tic
SetSoftwareProductToSoftwareRelease
PublishByActionSoftwareRelease
Logout
""" + self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginTestVifibCustomer
PersonRequestSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckGetSetConnectionDict
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionConnection))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionError(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.error
########################################
def test_ComputerPartition_error_afterRegister(self):
"""
Check that calling ComputerPartition.error after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = '\
SlapLoginTestVifibAdmin \
CustomerRegisterNewComputer \
Tic \
SlapLogout \
LoginTestVifibAdmin \
SetComputerCoordinatesFromComputerTitle \
ComputerSetAllocationScopeOpenPublic \
Tic \
Logout \
SlapLoginCurrentComputer \
FormatComputer \
Tic \
SlapLogout \
Tic \
SlapLoginCurrentComputer \
CheckNotFoundComputerPartitionErrorAfterRegisterCall \
CleanTic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_SetupResource_ConfirmedState(self):
"""
Check that calling ComputerPartition.error works in
confirmed state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_SetupResource_StartedState(self):
"""
Check that calling ComputerPartition.error works in
started state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_SetupResource_StoppedState(self):
"""
Check that calling ComputerPartition.error works in
stopped state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_SetupResource_DeliveredState(self):
"""
Check that calling ComputerPartition.error works in
delivered state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + '\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_HostingResource_ConfirmedState(self):
"""
Check that calling ComputerPartition.error works in
confirmed state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_start_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_HostingResource_StartedState(self):
"""
Check that calling ComputerPartition.error works in
started state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_HostingResource_StoppedState(self):
"""
Check that calling ComputerPartition.error works in
stopped state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stop_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_HostingResource_DeliveredState(self):
"""
Check that calling ComputerPartition.error works in
delivered state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_error_twoSalePackingList(self):
"""
Check that calling ComputerPartition.error uses the latest sale packing
list for calculation
"""
sequence_list = SequenceList()
sequence_string = self.prepare_start_requested_computer_partition_sequence_string + '\
LoginDefaultUser \
SetHostingAfterSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
LoginDefaultUser \
CheckSalePackingListNoErrorText \
SetHostingBeforeSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
Tic \
SlapLogout \
LoginDefaultUser \
CheckSalePackingListErrorText \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionError))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionGetInstanceParameterDict(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.getInstanceParameterDict
########################################
def test_ComputerPartition_getInstanceParameterDict_afterRegister(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict after just
registration works
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionGetInstanceParameterDictCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getInstanceParameterDict_confirmedState(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict works in
confirmed state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
CheckSuccessComputerPartitionGetInstanceParameterDictCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getInstanceParameterDict_startedState(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict works in
started state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
CheckSuccessComputerPartitionGetInstanceParameterDictCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getInstanceParameterDict_stoppedState(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict works in
stopped state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
CheckSuccessComputerPartitionGetInstanceParameterDictCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getInstanceParameterDict_emptyParameter(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict does
return minimal information in case no parameters are set
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
LoginERP5TypeTestCase \
FillTimestamp \
Logout \
SlapLoginCurrentSoftwareInstance \
CheckMinimalParametersTransmitted \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getInstanceParameterDict_validXML(self):
"""
Check that calling ComputerPartition.getInstanceParameterDict works
if the XML doesn't respect the XSD
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
LoginDefaultUser \
SetSoftwareInstanceValidXML \
Tic \
Logout \
LoginERP5TypeTestCase \
FillTimestamp \
Logout \
SlapLoginCurrentSoftwareInstance \
CheckComputerPartitionGetInstanceParameterDictResult \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionGetInstanceParameterDict))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionGetSoftwareRelease(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.getSoftwareRelease
########################################
def test_ComputerPartition_getSoftwareRelease_afterRegister(self):
"""
Check that calling ComputerPartition.getSoftwareRelease after just
registration raises a NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckNotFoundComputerPartitionGetSoftwareReleaseAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getSoftwareRelease_confirmedState(self):
"""
Check that calling ComputerPartition.getSoftwareRelease works in
confirmed state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionGetSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getSoftwareRelease_startedState(self):
"""
Check that calling ComputerPartition.getSoftwareRelease works in
started state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionGetSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getSoftwareRelease_stoppedState(self):
"""
Check that calling ComputerPartition.getSoftwareRelease works in
stopped state
"""
sequence_list = SequenceList()
sequence_string = self.prepare_installed_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionGetSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getSoftwareRelease_twoSalePackingList(self):
"""
Check that calling ComputerPartition.getSoftwareRelease """
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
LoginDefaultUser \
CheckPackingListAmountTwoComputerPartition \
SetHostingAfterSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionGetSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionGetSoftwareRelease))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionGetState(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.getState
########################################
def test_ComputerPartition_getState_emptyPartition(self):
"""
Check that calling ComputerPartition.getState after just
registration raises a NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckDestroyedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_SetupResource_ConfirmedState(self):
"""
Check that calling ComputerPartition.getState works in
confirmed state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_SetupResource_StartedState(self):
"""
Check that calling ComputerPartition.getState works in
started state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_SetupResource_StoppedState(self):
"""
Check that calling ComputerPartition.getState works in
stopped state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStoppedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_SetupResource_DeliveredState(self):
"""
Check that calling ComputerPartition.getState works in
delivered state with the setup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
LoginTestVifibCustomer \
SetSequenceSoftwareInstanceStateStopped \
PersonRequestSoftwareInstance \
Tic \
Logout \
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
SlapLoginCurrentComputer \
CheckStoppedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_HostingResource_ConfirmedState(self):
"""
Check that calling ComputerPartition.getState works in
confirmed state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_start_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_HostingResource_StartedState(self):
"""
Check that calling ComputerPartition.getState works in
started state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_HostingResource_StoppedState(self):
"""
Check that calling ComputerPartition.getState works in
stopped state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stop_requested_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStoppedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_HostingResource_DeliveredState(self):
"""
Check that calling ComputerPartition.getState works in
delivered state with the hosting resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckStoppedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_CleanupResource_ConfirmedState(self):
"""
Check that calling ComputerPartition.getState works in
confirmed state with the cleanup resource
"""
sequence_list = SequenceList()
sequence_string = self.prepare_destroy_requested_computer_partition + '\
SlapLoginCurrentComputer \
CheckDestroyedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_CleanupResource_DeliveredState(self):
"""
Check that calling ComputerPartition.getState works in
delivered state with the cleanup resource
"""
sequence_list = SequenceList()
sequence_string = self\
.prepare_destroyed_computer_partition + '\
SlapLoginCurrentComputer \
CheckDestroyedComputerPartitionGetStateCall \
SlapLoginCurrentComputer \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_getState_twoSalePackingList(self):
"""
Check that calling ComputerPartition.getState uses the latest sale packing
list for calculation
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + '\
LoginDefaultUser \
CheckPackingListAmountTwoComputerPartition \
SetHostingBeforeSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginDefaultUser \
SetHostingAfterSetupStartDate \
Tic \
Logout \
SlapLoginCurrentComputer \
CheckStartedComputerPartitionGetStateCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionGetState))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
class TestVifibSlapComputerPartitionGetStatus(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.getStatus
########################################
def stepCheckNoDataComputerPartitionGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
partition_id = sequence.get("computer_partition_reference",
sequence['computer_partition_reference_list'][0])
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer_partition = self.slap.registerComputerPartition(
computer_guid, partition_id)
status = computer_partition.getStatus()
self.assertEquals('SlapOS Master', status['user'])
self.assertEquals('#error no data found', status['text'])
def test_ComputerPartition_getStatus_emptyPartition(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckNoDataComputerPartitionGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckOKComputerPartitionGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
partition_id = sequence.get("computer_partition_reference",
sequence['computer_partition_reference_list'][0])
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer_partition = self.slap.registerComputerPartition(
computer_guid, partition_id)
status = computer_partition.getStatus()
self.assertEquals(sequence['software_instance_reference'], status['user'])
self.assertEquals('#access %s %s' % (
sequence['computer_reference'],
sequence['computer_partition_reference']),
status['text'])
def test_ComputerPartition_OK_getStatus(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
CheckSuccessSlapRegisterComputerPartitionCall \
SlapLogout \
SlapLoginCurrentComputer \
CheckOKComputerPartitionGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckErrorComputerPartitionGetStatusCall(self, sequence, **kw):
"""
"""
computer_guid = sequence["computer_reference"]
partition_id = sequence.get("computer_partition_reference",
sequence['computer_partition_reference_list'][0])
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
computer_partition = self.slap.registerComputerPartition(
computer_guid, partition_id)
status = computer_partition.getStatus()
self.assertEquals(sequence['computer_reference'], status['user'])
self.assertEquals('#error while instanciating', status['text'])
def test_ComputerPartition_Error_getStatus(self):
"""
"""
sequence_list = SequenceList()
sequence_string = self.prepare_building_computer_partition_sequence_string + '\
SlapLoginCurrentComputer \
CheckSuccessComputerPartitionErrorCall \
CheckErrorComputerPartitionGetStatusCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionGetStatus))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from zExceptions import Unauthorized
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestVifibSlapComputerPartitionLock(TestVifibSlapWebServiceMixin):
lock_user_sequence_string = '\
LoginERP5TypeTestCase \
CallSlaposTriggerBuildAlarm \
Tic \
CallStopConfirmedSaleInvoiceTransactionAlarm \
Tic \
CallSlaposTriggerBuildAlarm \
Tic \
Logout'
def stepSoftwareInstanceSaleOrderConfirmRaisesUnauthorized(self, sequence,
**kw):
"""Checks that current software instance is realted only with sale order
and that this sale order cannot be confirmed because of Unauthorized
It means that user has bad balance."""
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
aggregate_value_list = software_instance.getAggregateRelatedValueList(
portal_type=[self.sale_packing_list_line_portal_type,
self.sale_order_line_portal_type])
self.assertEqual(1, len(aggregate_value_list))
self.assertTrue(self.sale_order_line_portal_type in [q.getPortalType() for\
q in aggregate_value_list])
sale_order_line = aggregate_value_list[0]
sale_order = sale_order_line.getParentValue()
self.assertRaises(Unauthorized, sale_order.confirm)
def stepAssertNoComputerPartition(self, sequence, **kw):
"""Sets in sequence computer partition parameters related to current
software instance"""
software_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
delivery_line_list = [q for q in software_instance
.getAggregateRelatedValueList(
portal_type=self.sale_packing_list_line_portal_type)]
self.assertEqual(0, len(delivery_line_list))
@expectedFailure
# Balance check is disabled so test is irrelevant
def test_negative_person_balance_request(self):
"""Locked person can not request
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_software_release_sequence_string + \
self.register_new_user_sequence_string + \
self.lock_user_sequence_string + '\
LoginWebUser \
PersonRequestSoftwareInstance \
Tic \
Logout \
\
LoginDefaultUser \
SoftwareInstanceSaleOrderConfirmRaisesUnauthorized \
CallSlaposAllocateInstanceAlarm \
Tic \
AssertNoComputerPartition \
Logout \
\
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@expectedFailure
# Balance check is disabled so test is irrelevant
def test_negative_person_balance_request_slave(self):
"""Locked person can not request
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + \
self.register_new_user_sequence_string + \
self.lock_user_sequence_string + '\
LoginWebUser \
PersonRequestSlaveInstance \
Tic \
Logout \
\
LoginDefaultUser \
SoftwareInstanceSaleOrderConfirmRaisesUnauthorized \
CallSlaposAllocateInstanceAlarm \
Tic \
AssertNoComputerPartition \
Logout \
\
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionLock))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import skip
import urllib
import urlparse
import httplib
from xml_marshaller import xml_marshaller
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
class TestVifibSlapComputerPartitionRequest(TestVifibSlapWebServiceMixin):
########################################
# ComputerPartition.request
########################################
def test_ComputerPartition_request_noFreePartition(self):
"""
Check that first call to request raises NotFound response
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_noParameterInRequest(self):
"""
Check that it is possible to request another Computer Partition
from existing one, without passing any parameters and that in such case
original's Sofware Instance parameters will be passed.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
\
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
\
LoginTestVifibCustomer \
CheckViewCurrentSoftwareInstance \
CheckWriteCurrentSoftwareInstance \
Tic \
CheckViewRequestedSoftwareInstance \
CheckWriteRequestedSoftwareInstance \
Tic \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_instantiate(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and it is started correctly.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
\
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetInstanceStateStopped(self, sequence=None, **kw):
sequence['instance_state'] = 'stopped'
def test_ComputerPartition_request_instantiate_state_stopped(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and it is stopped correctly, as requested initally.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SetInstanceStateStopped \
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
SlapLogout \
\
LoginDefaultUser \
stepCheckComputerPartitionNoInstanceHostingSalePackingList \
Logout \
LoginTestVifibCustomer \
RequestSoftwareInstanceDestroy \
Tic \
Logout \
SlapLoginCurrentComputer \
SoftwareInstanceDestroyed \
Tic \
Tic \
SlapLogout \
LoginDefaultUser \
CheckComputerPartitionInstanceCleanupSalePackingListDelivered \
CheckComputerPartitionIsFree \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_instantiate_stop_later(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and it is started correctly, and later it is stopped
correctly as requested.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
\
SetInstanceStateStopped \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequester \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
CheckComputerPartitionInstanceHostingSalePackingListStopped \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStopped \
Logout \
\
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepDirectRequestComputerPartitionHttpRequestTimeoutResponseWithoutState(self,
sequence, **kw):
request_dict = { 'computer_id': sequence['computer_reference'] ,
'computer_partition_id': sequence['computer_partition_reference'],
'software_release': sequence['software_release_uri'],
'software_type': sequence.get('requested_software_type',
'requested_software_type'),
'partition_reference': sequence.get('requested_reference',
'requested_reference'),
'shared_xml': xml_marshaller.dumps(kw.get("shared", False)),
'partition_parameter_xml': xml_marshaller.dumps({}),
'filter_xml': xml_marshaller.dumps({}),
#'state': Note: State is omitted
}
scheme, netloc, path, query, fragment = urlparse.urlsplit(self.server_url)
connection = httplib.HTTPConnection(host=netloc)
connection.request("POST", path + '/requestComputerPartition',
urllib.urlencode(request_dict),
{'Content-type': "application/x-www-form-urlencoded"})
response = connection.getresponse()
self.assertEqual(httplib.REQUEST_TIMEOUT, response.status)
def test_ComputerPartition_request_state_is_optional(self):
"""Checks that state is optional parameter on Slap Tool
This ensures backward compatibility with old libraries."""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
DirectRequestComputerPartitionHttpRequestTimeoutResponseWithoutState \
Tic \
Tic \
SlapLogout \
\
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('This test fails because test_vifib_customer security is cached '
'and this user is not in SOFTINST-x group. We do not want to clear '
'cache in tests.')
def test_ComputerPartition_request_instantiateStop(self):
"""
Check that after computer partition is requested it is possible to
instantiate it and stop.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
CheckRequestedComputerPartitionCleanParameterList \
Logout \
\
LoginDefaultUser \
SetCurrentSoftwareInstanceRequested \
SetSelectedComputerPartition \
SelectCurrentlyUsedSalePackingListUid \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceBuilding \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStarted \
Logout \
\
LoginTestVifibCustomer \
RequestSoftwareInstanceStop \
Tic \
Logout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListStopped \
Logout \
\
SlapLoginCurrentComputer \
SoftwareInstanceStopped \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListDelivered \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_parameterInRequest(self):
"""
Check that it is possible to request another Computer Partition
from existing one, with passing parameters and that in such case all
passed parameters are available on new Computer Partition and no
parameters are copied.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SelectRequestedReference \
SelectRequestedParameterDictRequestedParameter \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
\
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionRequestedParameter \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_twiceSameSourceSameResult(self):
"""
Checks that requesting twice with same arguments from same Computer Partition
will return same object."""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SelectRequestedReference \
SelectEmptyRequestedParameterDict \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRaisesNotFoundComputerPartitionParameterDict \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckSoftwareInstanceAndRelatedComputerPartition \
CheckRequestedSoftwareInstanceAndRelatedComputerPartition \
Logout \
\
SlapLoginCurrentSoftwareInstance \
CheckRequestedComputerPartitionCleanParameterList \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_twiceDifferentParent(self):
"""
Checks that requesting twice with same arguments from different Computer
Partition will return same object.
This test is reproducing scenario:
Master
/ \
ChildrenA ChildrenB
\
ChildrenRequestedTwice
Then ChildrenB requests ChildrenRequestedTwice, so graph changes to:
Master
/ \
ChildrenA ChildrenB
/
ChildrenRequestedTwice
"""
self.computer_partition_amount = 4
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
# Generate first part of graph
# Master
# / \
# ChildrenA ChildrenB
# \
# ChildrenRequestedTwice
LoginDefaultUser
SetSoftwareInstanceChildrenA
SelectRequestedReference
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetRequestedComputerPartition
CheckComputerPartitionChildrenA
CheckComputerPartitionChildrenBNoChild
CheckComputerPartitionRequestedDoubleScenarioChildrenA
Logout
# Generate second part of graph
# Master
# / \
# ChildrenA ChildrenB
# /
# ChildrenRequestedTwice
LoginDefaultUser
SetRequestedComputerPartition
SetSoftwareInstanceChildrenB
SelectRequestedReference
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetRequestedComputerPartition
CheckComputerPartitionChildrenANoChild
CheckComputerPartitionChildrenB
CheckComputerPartitionRequestedDoubleScenarioChildrenB
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_SlaveInstance_twiceDifferentParent(self):
"""
Checks that requesting a Slave Instance twice with same arguments from
different Computer Partition will return same object.
This test is reproducing scenario:
Master
/ \
ChildrenA ChildrenB
\
SlaveInstanceRequestTwice
Then ChildrenB requests SlaveInstanceRequestedTwice, so graph changes to:
Master
/ \
ChildrenA ChildrenB
/
SlaveInstanceRequestedTwice
"""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
# Generate first part of graph
# Master
# / \
# ChildrenA ChildrenB
# \
# SlaveInstanceRequestedTwice
LoginDefaultUser
SetSoftwareInstanceChildrenA
SelectRequestedReference
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetRequestedComputerPartition
CheckComputerPartitionChildrenA
CheckComputerPartitionChildrenBNoChild
Logout
# Generate second part of graph
# Master
# / \
# ChildrenA ChildrenB
# /
# SlaveInstanceRequestedTwice
LoginDefaultUser
SetRequestedComputerPartition
SetSoftwareInstanceChildrenB
SelectRequestedReference
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetRequestedComputerPartition
CheckComputerPartitionChildrenANoChild
CheckComputerPartitionChildrenB
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Implementation is not ready yet')
def test_ComputerPartition_request_twiceDifferentParentWithoutTic(self):
"""
Checks that requesting twice with same arguments from different Computer
Partition will return same object.
This test is reproducing scenario:
Master
/ \
ChildrenA ChildrenB
\
ChildrenRequestedTwice
Then ChildrenB requests ChildrenRequestedTwice, so graph changes to:
Master
/ \
ChildrenA ChildrenB
/
ChildrenRequestedTwice
Case without tic between requests.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
SelectRequestedReference
SelectEmptyRequestedParameterDict
SetSoftwareInstanceChildrenA
RequestComputerPartition
Tic
SetSoftwareInstanceChildrenB
RequestComputerPartition
Tic
SetRequestedComputerPartition
CheckComputerPartitionChildrenA
CheckComputerPartitionChildrenB
CheckComputerPartitionRequestedDoubleScenario
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_differentSourceDifferentResultWithTic(self):
"""
Check that requesting different Computer Partitions from different sources
gives different result, because they are requesting different
partition_reference.
This test is reproducing scenario:
Master
/ \
ChildrenA ChildrenB
| |
ChildChildA ChildChildB
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
# Request ChildChildrenA
LoginDefaultUser
SetSoftwareInstanceChildrenA
SelectRequestedReferenceChildrenAChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetChildrenAChildComputerPartition
# Request ChilChildrenB
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetChildrenBChildComputerPartition
# Do assertions
CheckComputerPartitionChildrenAWithOwnChildren
CheckComputerPartitionChildrenBWithOwnChildren
CheckComputerPartitionChildrenAChild
CheckComputerPartitionChildrenBChild
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Implementation is not ready yet.')
def test_ComputerPartition_request_differentSourceDifferentResultWithoutTic(
self):
"""
Check that requesting different Computer Partitions from different sources
gives different result, because they are requesting different
partition_reference.
This test is reproducing scenario:
Master
/ \
ChildrenA ChildrenB
| |
ChilChildA ChildChildB
Case without tic between requests.
"""
self.computer_partition_amount = 5
sequence_list = SequenceList()
sequence_string = self.prepare_children_a_children_b_sequence_string + """
LoginDefaultUser
SetSoftwareInstanceChildrenA
SelectRequestedReferenceChildrenAChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetChildrenAChildComputerPartition
SetSoftwareInstanceChildrenB
SelectRequestedReferenceChildrenBChild
SelectEmptyRequestedParameterDict
Logout
SlapLoginCurrentSoftwareInstance
RequestComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetChildrenBChildComputerPartition
CheckComputerPartitionChildrenAWithOwnChildren
CheckComputerPartitionChildrenBWithOwnChildren
CheckComputerPartitionChildrenAChild
CheckComputerPartitionChildrenBChild
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_serialiseIsCalled(self):
"""
Check that during ComputerPartition.request serialise is being called
on being choosen Computer Partition.
Serialize call is used to protect Computer Partition from being selected
as free in case of concurrency connections.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
SelectRequestedReferenceChildrenA \
SelectEmptyRequestedParameterDict \
RequestComputerPartitionNoTic \
CleanTic \
SlapLogout \
LoginDefaultUser \
CallOrderPlannedSaleOrderAlarm \
CleanTic \
ConfirmSaleOrderOrderedToCheckSerializeCalledOnSelected \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
########################################
# ComputerPartition.request - filter - computer_guid
########################################
def test_ComputerPartition_request_filter_computer_guid(self):
"""
Check that requesting with filter computer_guid key works as expected
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
# There are two partitions on another computer
# so request shall be processed twice correctly, 3rd time it shall
# fail
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + \
self.prepare_another_computer_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
SelectAnotherRequestedReference \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
\
SelectYetAnotherRequestedReference \
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
########################################
# ComputerPartition.request - slave
########################################
def test_ComputerPartition_request_slave_simpleCase(self):
"""
Check the most simple case of request. The behaviour should
keep the same as Software Instance.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string +\
"""
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict \
SetRandomRequestedReference \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_slave_instantiate(self):
"""
Check that one Slave Instance is instantiate correctly and the validate
the Sale Packing List states
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string +\
"""
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
Tic
CheckRaisesNotFoundComputerPartitionParameterDict
Tic
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentSoftwareInstance
CheckSlaveInstanceListFromOneComputerPartition
SelectSlaveInstanceFromOneComputerPartition
SlapLogout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceSetupSalePackingListDelivered
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser \
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
SlapLoginCurrentComputer \
SoftwareInstanceStarted \
Tic \
SlapLogout \
\
LoginDefaultUser \
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_slave_same_twice_SR(self):
"""
Check that requesting the same slave instance twice, only one is created
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string +\
"""
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SelectRequestedReference
RequestSlaveInstanceFromComputerPartition \
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLogout
SlapLoginCurrentSoftwareInstance \
RequestSlaveInstanceFromComputerPartition \
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_slave_after_destroy_SlaveInstance(self):
"""
Check that a Slave Instance will not be allocated when a Software
Instance is destroyed
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
SlapLogout
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SelectRequestedReference
RequestSlaveInstanceFromComputerPartition
Tic
LoginDefaultUser
SelectSlaveInstanceFromSaleOrderOrdered
SoftwareInstanceFailedAllocation
CallSlaposAllocateInstanceAlarm
Tic
SetDeliveryLineAmountEqualZero
CheckComputerPartitionInstanceSetupSalePackingListDelivered
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_slave_twice_different(self):
"""
Check request 2 different slave instances on same Software
Instance.
"""
simple_request_with_random = """
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict \
SetRandomRequestedReference \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string +\
simple_request_with_random + """
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLogout
""" + \
simple_request_with_random + \
"""
SlapLoginCurrentComputer
CheckTwoSlaveInstanceListFromOneComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_slave_NotFound(self):
"""
Check that requesting a Slave Instance works in system capable to fulfill
such request, when Software Instance is not installed yet.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + """
LoginDefaultUser
SetRandomComputerPartition
SlapLoginCurrentComputer
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
SelectNewSoftwareReleaseUri
RequestSlaveInstanceFromComputerPartitionNotFoundError
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepDirectRequestComputerPartitionHttpRequestTimeoutResponseWithoutStateAndSharedTrue(
self, sequence, **kw):
kw["shared"] = True
self.stepDirectRequestComputerPartitionHttpRequestTimeoutResponseWithoutState(
sequence, **kw)
def test_ComputerPartition_request_slave_state_is_optional(self):
"""Checks that state is optional parameter on Slap Tool This ensures
backward compatibility with old libraries."""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
DirectRequestComputerPartitionHttpRequestTimeoutResponseWithoutStateAndSharedTrue \
Tic \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetRequestedWrongFilterParameterDict(self, sequence):
sequence['requested_filter_dict'] = dict(
computer_guid="COMP-99999999999999999999999")
def test_ComputerPartition_request_filter_slave_computer_guid(self):
"""Check that requesting with filter computer_guid key works as expected.
This include tests for slave instance case."""
self.computer_partition_amount = 2
sequence_list = SequenceList()
# There are two partitions on another computer
# so request shall be processed twice correctly, 3rd time it shall
# fail
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + \
self.prepare_another_computer_sequence_string + '\
SelectAnotherRequestedReference \
SelectEmptyRequestedParameterDict \
SlapLoginCurrentSoftwareInstance \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
SelectSlaveInstanceFromSaleOrderOrdered \
SoftwareInstanceFailedAllocation \
Tic \
Logout \
SlapLoginCurrentSoftwareInstance \
SetRequestedFilterParameterDict \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
SetDeliveryLineAmountEqualOne \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
\
SetRequestedWrongFilterParameterDict \
SelectYetAnotherRequestedReference \
SlapLoginCurrentSoftwareInstance \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
CheckComputerPartitionInstanceSetupSalePackingListDelivered \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckConnectionXmlOfSlaveInstanceFromComputerPartition(self, sequence):
computer_reference = sequence["computer_reference"]
computer_partition_reference = sequence["computer_partition_reference"]
slave_reference = sequence["requested_reference"]
slave_software_release = sequence["software_release_uri"]
slave_software_type = sequence["requested_software_type"]
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
# Get Computer Partition
computer_partition = self.slap.registerComputerPartition(
computer_reference, computer_partition_reference)
# Get slave
slave_instance = computer_partition.request(
software_release=slave_software_release,
software_type=slave_software_type,
partition_reference=slave_reference,
shared=True,
)
self.assertEquals(sequence["slave_instance_site_url"],
slave_instance.getConnectionParameter("site_url"))
def test_SlaveInstance_request_SlaveInstance_From_SoftwareInstance(self):
"""
Check that existing Software Instance can request new Slave Instance
and access to its parameters.
Scenario :
All Software Instances use the same SoftwareRelease.
SoftwareType requested_software_type can act as master instance, slave
instance.
SoftwareType another_requested_software_type can act as Software Instance
requesting a Slave Instance of SoftwareType requested_software_type.
1/ Request instance "Master Instance" with SoftwareType
requested_software_type.
2/ Simulate succesful deployment of instance
3/ Request instance "Normal instance" with SoftwareType
another_requested_software_type.
4/ From "Normal Instance", request a Slave Instance with SoftwareType
requested_software_type.
5/ From "Master Instance", try to set connection XML of Slave Instance
5/ Check that "Normal Instance" can access connection XML of Slave
Instance.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + '\
Tic \
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
CheckEmptySlaveInstanceListFromOneComputerPartition \
\
SelectAnotherRequestedSoftwareType \
SelectAnotherRequestedReference \
SlapLoginTestVifibCustomer \
PersonRequestSlapSoftwareInstancePrepare \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
SlapLoginTestVifibCustomer \
PersonRequestSlapSoftwareInstance \
Tic \
SlapLogout \
LoginDefaultUser \
SetRequestedComputerPartition \
SetRequestedComputerPartitionAsCurrentComputerPartition \
SlapLogout \
Tic \
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
\
LoginDefaultUser \
SetCurrentComputerPartitionFromRequestedComputerPartition \
SelectSoftwareInstanceFromCurrentComputerPartition \
Logout \
SlapLoginCurrentSoftwareInstance \
SelectRequestedParameterDictRequestedParameter \
SelectYetAnotherRequestedReference \
SelectRequestedSoftwaretype \
RequestSlaveInstanceFromComputerPartition \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
SetComputerPartitionFromRootSoftwareInstance \
SelectSlaveInstanceFromOneComputerPartition \
SlapLoginSoftwareInstanceFromCurrentSoftwareInstance \
SetConnectionXmlToSlaveInstance \
SlapLogout \
LoginDefaultUser \
SetRequestedComputerPartitionAsCurrentComputerPartition \
SelectSoftwareInstanceFromCurrentComputerPartition \
Logout \
SlapLoginCurrentSoftwareInstance \
CheckConnectionXmlOfSlaveInstanceFromComputerPartition \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_request_SlaveInstance_From_SoftwareInstance_Fetch_Correct_Slave(self):
"""
Check that existing Software Instance requesting new Slave Instance
fetches the correct Slave Instance when doing request() to get
parameters.
Scenario :
All Software Instances use the same SoftwareRelease.
SoftwareType requested_software_type can act as master instance, slave
instance.
SoftwareType another_requested_software_type can act as Software Instance
requesting a Slave Instance of SoftwareType requested_software_type.
1/ Request instance "Master Instance" with SoftwareType
requested_software_type.
2/ "Master Instance" requests a new Slave Instance
3/ Simulate succesful deployment of Master Instance
4/ Request instance "Normal instance" with SoftwareType
another_requested_software_type.
5/ From "Normal Instance", request a Slave Instance with SoftwareType
requested_software_type.
6/ From "Master Instance", try to set connection XML of Slave Instance
7/ Check that "Normal Instance" can access connection XML of Slave
Instance.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + '\
SlapLoginCurrentSoftwareInstance \
SelectEmptyRequestedParameterDict \
SetRandomRequestedReference \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
SlapLoginCurrentComputer \
CheckSlaveInstanceListFromOneComputerPartition \
SlapLogout \
\
Tic \
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
\
SelectAnotherRequestedSoftwareType \
SelectAnotherRequestedReference \
SlapLoginTestVifibCustomer \
PersonRequestSlapSoftwareInstancePrepare \
Tic \
SlapLogout \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
SlapLoginTestVifibCustomer \
PersonRequestSlapSoftwareInstance \
Tic \
SlapLogout \
LoginDefaultUser \
SetRequestedComputerPartition \
SetRequestedComputerPartitionAsCurrentComputerPartition \
SlapLogout \
Tic \
SlapLoginCurrentComputer \
SoftwareInstanceAvailable \
Tic \
\
LoginDefaultUser \
SetCurrentComputerPartitionFromRequestedComputerPartition \
SelectSoftwareInstanceFromCurrentComputerPartition \
Logout \
SlapLoginCurrentSoftwareInstance \
SelectRequestedParameterDictRequestedParameter \
SelectYetAnotherRequestedReference \
SelectRequestedSoftwaretype \
RequestSlaveInstanceFromComputerPartition \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
RequestSlaveInstanceFromComputerPartition \
Tic \
SlapLogout \
LoginDefaultUser \
SetComputerPartitionFromRootSoftwareInstance \
SelectSlaveInstanceFromOneComputerPartition \
SlapLoginSoftwareInstanceFromCurrentSoftwareInstance \
SetConnectionXmlToSlaveInstance \
SlapLogout \
LoginDefaultUser \
SetRequestedComputerPartitionAsCurrentComputerPartition \
SelectSoftwareInstanceFromCurrentComputerPartition \
Logout \
SlapLoginCurrentSoftwareInstance \
CheckConnectionXmlOfSlaveInstanceFromComputerPartition \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
##################################################
# ComputerPartition.request - change software type
##################################################
def stepSetFirstSoftwareType(self, sequence,
**kw):
sequence.edit(requested_software_type="FirstSoftwareType")
def stepSelectSlaveInstanceFromSaleOrderOrdered(self, sequence):
order_line = self.portal.portal_catalog.getResultValue(
portal_type="Sale Order Line", simulation_state="ordered")
slave_instance_uid = order_line.getAggregateValue(
portal_type="Slave Instance").getUid()
sequence.edit(software_instance_uid=slave_instance_uid)
def stepRequestComputerPartitionWithAnotherSoftwareType(self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type="SecondSoftwareType",
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
slap_computer_partition.request(**kw)
def stepCheckRequestComputerPartitionWithAnotherSoftwareType(
self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type="SecondSoftwareType",
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
requested_slap_computer_partition = slap_computer_partition.request(**kw)
self.assertEquals(sequence.get('requested_computer_partition_reference'),
requested_slap_computer_partition.getId())
self.assertEquals("SecondSoftwareType",
requested_slap_computer_partition.getInstanceParameterDict()['slap_software_type'])
self.assertEquals(1,
requested_slap_computer_partition._need_modification)
def stepCheckRequestComputerPartitionWithAnotherSoftwareRelease(
self, sequence, **kw):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
slap_computer_partition = self.slap.registerComputerPartition(
sequence['computer_reference'],
sequence['computer_partition_reference'])
kw = dict(software_release=sequence['software_release_uri'],
software_type=sequence.get('requested_software_type', 'software_type'),
partition_reference=sequence.get('requested_reference',
'requested_reference'),
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}),
state=sequence.get('instance_state'))
requested_slap_computer_partition = slap_computer_partition.request(**kw)
self.assertEquals(sequence.get('requested_computer_partition_reference'),
requested_slap_computer_partition.getId())
self.assertEquals(sequence['software_release_uri'],
requested_slap_computer_partition.getSoftwareRelease().getURI())
self.assertEquals(1,
requested_slap_computer_partition._need_modification)
def test_ComputerPartition_request_changeSoftwareType(self):
"""
Check that requesting the same instance with a different software type
does not create a new instance
"""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SelectRequestedReference \
SelectEmptyRequestedParameterDict \
\
SlapLoginCurrentSoftwareInstance \
SetFirstSoftwareType \
RequestComputerPartition \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
RequestComputerPartition \
Tic \
RequestComputerPartitionWithAnotherSoftwareType \
Tic \
RequestComputerPartitionWithAnotherSoftwareType \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
CheckRequestComputerPartitionWithAnotherSoftwareType \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_request_changeSoftwareRelease(self):
"""
Check that requesting the same instance with a different software release
does not create a new instance
"""
self.computer_partition_amount = 3
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + '\
SelectRequestedReference \
SelectEmptyRequestedParameterDict \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic ' + self.prepare_published_software_release + '\
LoginTestVifibAdmin \
RequestSoftwareInstallation \
Tic \
Logout \
\
SlapLoginCurrentComputer \
ComputerSoftwareReleaseAvailable \
Tic \
SlapLogout \
\
SlapLoginCurrentSoftwareInstance \
RequestComputerPartition \
Tic \
RequestComputerPartition \
Tic \
LoginDefaultUser \
CallSlaposAllocateInstanceAlarm \
Tic \
Logout \
CheckRequestComputerPartitionWithAnotherSoftwareRelease \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionRequest))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapComputerPartitionStopped(TestVifibSlapWebServiceMixin):
def test_ComputerPartition_stopped(self):
sequence_list = SequenceList()
sequence_string = self\
.prepare_stopped_computer_partition_sequence_string + """
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_stopped_destroy_requested(self):
"""Checks that stopped does not raise in case if destroy was requested"""
sequence_list = SequenceList()
sequence_string = self\
.prepare_stopped_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
CheckComputerPartitionInstanceHostingSalePackingListDelivered
Logout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_ComputerPartition_stopped_destroy_requested_started(self):
"""Checks that stopped does not raise in case if destroy was requested
on started one"""
sequence_list = SequenceList()
sequence_string = self\
.prepare_started_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionStopped))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from random import random
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
import transaction
from _mysql_exceptions import DataError
class TestVifibSlapComputerPartitionUpdate(TestVifibSlapWebServiceMixin):
def stepRequestSoftwareInstanceUpdate(self, sequence, **kw):
instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
if instance.getPortalType() == "Software Instance":
shared = False
elif instance.getPortalType() == "Slave Instance":
shared = True
else:
raise NotImplementedError
method_dict = {
'start_requested': instance.requestStart,
'stop_requested': instance.requestStop,
'destroy_requested': instance.requestDestroy,
}
method_dict[instance.getSlapState()](
software_release=instance.getUrlString(),
instance_xml='<?xml version="1.0" ' \
'encoding="utf-8"?><instance><parameter id="foo">bar</parameter></instance>',
software_type=instance.getSourceReference(),
sla_xml=instance.getSlaXml(),
shared=shared,
)
def stepCheckComputerPartitionInstanceUpdateSalePackingListDelivered(self,
sequence, **kw):
self._checkComputerPartitionSalePackingListState('delivered',
self.portal.portal_preferences.getPreferredInstanceUpdateResource(),
sequence)
def stepPersonRequestStoppedSoftwareInstance(self, sequence, **kw):
self.stepPersonRequestSoftwareInstance(sequence, state='stopped')
def stepCheckComputerPartitionNoInstanceUpdateSalePackingList(self,
sequence, **kw):
self._checkComputerPartitionNoSalePackingList(
self.portal.portal_preferences.getPreferredInstanceUpdateResource(),
sequence)
# expected scenarios
def test_update_support_stopped_instance_setup(self):
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginTestVifibCustomer
PersonRequestStoppedSoftwareInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
SlapLoginCurrentComputer
SoftwareInstanceBuilding
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceSetupSalePackingListDelivered
Logout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetSelectedComputerPartition
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionNoInstanceHostingSalePackingList
Logout
# prepared initally stopped instance
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentComputer
CheckStoppedComputerPartitionGetStateCall
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionNoInstanceHostingSalePackingList
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_support_started_instance_hosting(self):
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string \
+ """
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentComputer
CheckStartedComputerPartitionGetStateCall
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStarted
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_support_delivered_instance_hosting(self):
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string \
+ """
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentComputer
CheckStoppedComputerPartitionGetStateCall
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
SlapLogout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceHostingSalePackingListStopped
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckUpdateSalePackingListErrorText(self, sequence, **kw):
"""
Check that the sale packing list has an error log
"""
computer_partition = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_partition_uid'])
packing_list_line = [q for q in computer_partition
.getAggregateRelatedValueList(
portal_type=self.sale_packing_list_line_portal_type)
if q.getResource() == \
self.portal.portal_preferences.getPreferredInstanceUpdateResource()][0]
packing_list = packing_list_line.getParentValue()
self.assertFalse(packing_list.getComment('').endswith("ErrorLog"))
def test_update_support_error(self):
sequence_list = SequenceList()
sequence_string = self.prepare_stopped_computer_partition_sequence_string \
+ """
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentComputer
CheckStoppedComputerPartitionGetStateCall
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerPartitionErrorCall
Tic
SlapLogout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceHostingSalePackingListStopped
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
CheckUpdateSalePackingListErrorText
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
# ignored scenarios
def test_update_not_created_confirmed_instance_setup(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_install_requested_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_not_created_started_instance_setup(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_building_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_not_created_confirmed_instance_hosting(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_not_created_stopped_instance_hosting(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_stop_requested_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
SetDeliveryLineAmountEqualTwo
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Update is forbidden on destroyed instance')
def test_update_not_created_confirmed_instance_cleanup(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_destroy_requested_computer_partition + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionNoInstanceUpdateSalePackingList
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('Update is forbidden on destroyed instance')
def test_update_not_created_started_instance_cleanup(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_destroy_requested_computer_partition + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdate
Tic
Logout
LoginDefaultUser
CheckComputerPartitionNoInstanceUpdateSalePackingList
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepRequestSoftwareInstanceUpdateRaisesValidationFailed(self, sequence,
**kw):
instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid'])
if instance.getPortalType() == "Software Instance":
shared = False
elif instance.getPortalType() == "Slave Instance":
shared = True
else:
raise NotImplementedError
method_dict = {
'start_requested': instance.requestStart,
'stop_requested': instance.requestStop,
'destroy_requested': instance.requestDestroy,
}
self.assertRaises(UnsupportedWorkflowMethod,
method_dict[instance.getSlapState()],
software_release=instance.getUrlString(),
instance_xml=instance.getTextContent(),
software_type=instance.getSourceReference(),
sla_xml=instance.getSlaXml(),
shared=shared,
)
def test_update_not_possible_delivered_instance_cleanup(self):
sequence_list = SequenceList()
sequence_string = \
self.prepare_destroyed_computer_partition + """
LoginTestVifibCustomer
RequestSoftwareInstanceUpdateRaisesValidationFailed
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckActivityPersonRequestInProgress(self, sequence, **kw):
person_uid = self.portal.ERP5Site_getAuthenticatedMemberPersonValue(
'test_vifib_customer').getUid()
software_title = sequence['root_software_instance_title']
tag = "%s_%s_inProgress" % (person_uid,
software_title)
self.assertNotEqual(0, self.portal.portal_activities.
countMessageWithTag(tag))
def stepPersonRequestSoftwareInstanceNoTic(self, sequence, **kw):
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue()
software_release = self.portal.portal_catalog.getResultValue(
uid=sequence['software_release_uid'])
person.requestSoftwareInstance(
software_release=software_release.getUrlString(),
software_title=self.root_software_instance_title,
software_type="RootSoftwareInstance",
instance_xml=self.minimal_correct_xml,
sla_xml="",
shared=False,
state="started")
sequence.edit(root_software_instance_title=self.root_software_instance_title,
hosting_subscription_uid=self.REQUEST['request_hosting_subscription'].getUid())
def stepPersonRequestSoftwareInstanceNoTicRaisesDataError(self, sequence, **kw):
person = self.portal.ERP5Site_getAuthenticatedMemberPersonValue()
software_release = self.portal.portal_catalog.getResultValue(
uid=sequence['software_release_uid'])
person.requestSoftwareInstance(
software_release=software_release.getUrlString(),
software_title=self.root_software_instance_title,
software_type="RootSoftwareInstance",
instance_xml=self.minimal_correct_xml,
sla_xml="",
shared=False,
state="started")
self.assertRaises(DataError, self.commit)
transaction.abort()
def stepCheckUpdateNotCreatedSiteConsistency(self, sequence, **kw):
self.portal.portal_alarms.vifib_check_consistency.activeSense()
transaction.commit()
self.tic()
consistency_error_list = self.portal.portal_alarms.vifib_check_consistency\
.Alarm_getConsistencyCheckReportLineList()
self.assertEqual(1, len(consistency_error_list))
consistency_error = consistency_error_list[0]
order_line = self.portal.portal_catalog.getResultValue(
uid=sequence['hosting_subscription_uid']).getAggregateRelatedValue(
portal_type='Sale Order Line')
self.assertEqual(consistency_error.getObject().getPath(),
order_line.getPath())
self.assertEqual(
consistency_error.mapping,
{'max_arity': 1, 'portal_type': 'Software Release', 'min_arity': 1,
'current_arity': 0, 'base_category': ['aggregate']}
)
self.assertTrue(self.portal.portal_alarms.vifib_check_consistency.sense())
self.checkDivergency()
def test_update_not_created_person_request_in_progress(self):
self.root_software_instance_title = self.id() + str(random())
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginTestVifibCustomer
PersonRequestSoftwareInstanceNoTic
Logout
LoginDefaultUser
CheckActivityPersonRequestInProgress
Logout
# and this that test finishes
# it is proven that person data are begin in progress
# but there is no way to request software instance update as...
# ...it does not exists yet
LoginERP5TypeTestCase
CheckUpdateNotCreatedSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_update_not_created_person_request_in_progress_long_title(self):
self.root_software_instance_title = 'a' * 256 # longer then SQL column size
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginTestVifibCustomer
PersonRequestSoftwareInstanceNoTicRaisesDataError
Logout
# and this that test finishes
# it is proven that person data are begin in progress
# but there is no way to request software instance update as...
# ...it does not exists yet
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapComputerPartitionUpdate))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
class TestVifibSlapOpenOrderRequest(TestVifibSlapWebServiceMixin):
########################################
# OpenOrder.request
########################################
def test_person_request_ComputerPartition_filter_computer_guid(self):
"""Check that requesting with computer_guid in filter_kw works as
expected in case of person request"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
# There is only one partition on each computer, which has installed
# software release. But as request has sla parameter, the partition
# on another computer is not selected, as not following SLA.
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
""" + \
self.prepare_another_computer_sequence_string + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckPersonRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
SelectYetAnotherRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
SoftwareInstanceFailedAllocation
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_person_request_ComputerPartition(self):
"""Checks that Person using Slap interface is able to request Computer
Partition"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckPersonRequestedSoftwareInstanceAndRelatedComputerPartition
Logout
SlapLoginCurrentSoftwareInstance
CheckRequestedComputerPartitionCleanParameterList
SlapLogout
LoginTestVifibCustomer
CheckViewCurrentSoftwareInstance
CheckWriteCurrentSoftwareInstance
Tic
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetSequenceSoftwareInstanceRequestedStateDestroyed(self, sequence, **kw):
sequence['requested_state'] = 'destroyed'
def test_person_destroy_not_instanciable_software_instance(self):
"""Check that if there is no way to instantiate software instance
on any partition person is able to destroy it"""
self.computer_partition_amount = 0
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
SlapLogout
LoginDefaultUser
SetCurrentPersonSlapRequestedSoftwareInstance
CheckSoftwareInstanceNoDeliveryRelated
Logout
SlapLoginTestVifibCustomer
SetSequenceSoftwareInstanceRequestedStateDestroyed
PersonRequestSlapSoftwareInstance
Tic
Logout
LoginDefaultUser
CheckSoftwareInstanceCancelledSaleOrderLine
Tic # in order to give chance to update Open Order
CheckOpenOrderLineRemoved
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetFirstSoftwareType(self, sequence,
**kw):
sequence.edit(software_type="FirstSoftwareType")
def stepPersonRequestSlapSoftwareInstanceWithAnotherSoftwareType(
self, sequence, **kw):
software_release = sequence['software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
open_order.request(
software_release=software_release,
software_type="SecondSoftwareType",
partition_reference=sequence['requested_reference'],
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}))
def stepCheckPersonRequestSlapSoftwareInstanceWithAnotherSoftwareType(
self, sequence, **kw):
software_release = sequence['software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
requested_slap_computer_partition = open_order.request(
software_release=software_release,
software_type="SecondSoftwareType",
partition_reference=sequence['requested_reference'],
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}))
self.assertEquals(sequence.get('requested_computer_partition_reference'),
requested_slap_computer_partition.getId())
self.assertEquals("SecondSoftwareType",
requested_slap_computer_partition.getInstanceParameterDict()['slap_software_type'])
self.assertEquals(1,
requested_slap_computer_partition._need_modification)
def stepPersonRequestSlapSoftwareInstanceWithAnotherSoftwareRelease(
self, sequence, **kw):
software_release = sequence['another_software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
open_order.request(
software_release=software_release,
software_type=sequence.get('requested_software_type', 'software_type'),
partition_reference=sequence['requested_reference'],
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}))
def stepCheckPersonRequestSlapSoftwareInstanceWithAnotherSoftwareRelease(
self, sequence, **kw):
software_release = sequence['another_software_release_uri']
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
open_order = self.slap.registerOpenOrder()
requested_slap_computer_partition = open_order.request(
software_release=software_release,
software_type=sequence.get('requested_software_type', 'software_type'),
partition_reference=sequence['requested_reference'],
partition_parameter_kw=sequence.get('requested_parameter_dict', {}),
filter_kw=sequence.get('requested_filter_dict', {}))
self.assertEquals(sequence.get('requested_computer_partition_reference'),
requested_slap_computer_partition.getId())
self.assertEquals(software_release,
requested_slap_computer_partition.getSoftwareRelease().getURI())
self.assertEquals(1,
requested_slap_computer_partition._need_modification)
def test_OpenOrder_request_changeSoftwareType(self):
"""
Check that requesting the same instance with a different software type
does not create a new instance
"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
SetFirstSoftwareType
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
PersonRequestSlapSoftwareInstanceWithAnotherSoftwareType
Tic
CheckPersonRequestSlapSoftwareInstanceWithAnotherSoftwareType
Tic
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepStoreAnotherSoftwareRelease(self, sequence, **kw):
sequence['another_software_release_uri'] = sequence['software_release_uri']
def test_OpenOrder_request_changeSoftwareRelease(self):
"""
Check that requesting the same instance with a different software release
does not create a new instance
"""
self.computer_partition_amount = 1
sequence_list = SequenceList()
sequence_string = self.prepare_published_software_release + \
self.prepare_formated_computer + """
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
StoreAnotherSoftwareRelease
""" + self.prepare_published_software_release + \
"""
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
SetRandomRequestedReference
SlapLoginTestVifibCustomer
SetFirstSoftwareType
PersonRequestSlapSoftwareInstancePrepare
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginTestVifibCustomer
PersonRequestSlapSoftwareInstance
Tic
PersonRequestSlapSoftwareInstanceWithAnotherSoftwareRelease
Tic
CheckPersonRequestSlapSoftwareInstanceWithAnotherSoftwareRelease
Tic
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapOpenOrderRequest))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapRegisterComputer(TestVifibSlapWebServiceMixin):
########################################
# slap.registerComputer
########################################
def test_slap_registerComputer_unknowComputerUid(self):
"""
Check the slap.registerComputer without any Computer document
does not fail
"""
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + '\
SetRandomComputerReference \
LoginDefaultUser \
CheckSuccessSlapRegisterComputerCall \
Logout \
Tic \
LoginDefaultUser \
CheckUnexistingComputer \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputer_draftComputer(self):
"""
Check the slap.registerComputer does not fail if
a draft computer exits.
"""
sequence_list = SequenceList()
# Note: ERP5TypeTestCase is used as login to being able to test it
sequence_string = self.stabilise_accounting + '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout \
\
LoginDefaultUser \
CheckSuccessSlapRegisterComputerCall \
Logout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputer_validatedComputer(self):
"""
Check the slap.registerComputer does not fail if
a validated computer exists.
"""
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + '\
SlapLoginTestVifibAdmin \
CustomerRegisterNewComputer \
Tic \
SlapLogout \
LoginTestVifibAdmin \
SetComputerCoordinatesFromComputerTitle \
ComputerSetAllocationScopeOpenPublic \
Tic \
Logout \
\
SlapLoginCurrentComputer\
CheckSuccessSlapRegisterComputerCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputer_TwoValidatedComputer(self):
"""
Check the slap.registerComputer works in case of more then one computer available
"""
sequence_list = SequenceList()
sequence_string = self.stabilise_accounting + '\
SlapLoginTestVifibAdmin \
CustomerRegisterNewComputer \
Tic \
SlapLogout \
LoginTestVifibAdmin \
SetComputerCoordinatesFromComputerTitle \
ComputerSetAllocationScopeOpenPublic \
Tic \
Logout \
\
SlapLoginTestVifibAdmin \
CustomerRegisterNewComputer \
Tic \
SlapLogout \
LoginTestVifibAdmin \
SetComputerCoordinatesFromComputerTitle \
ComputerSetAllocationScopeOpenPublic \
Tic \
Logout \
\
SlapLoginCurrentComputer\
CheckSuccessSlapRegisterComputerCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapRegisterComputer))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import skip
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapRegisterComputerPartition(TestVifibSlapWebServiceMixin):
########################################
# slap.registerComputerPartition
########################################
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_slap_registerComputerPartition_unknowComputerUid(self):
"""
Check the slap.registerComputerPartition without any Computer document
fails.
"""
sequence_list = SequenceList()
sequence_string = '\
SlapLoginRandomComputer \
CheckUnauthorizedSlapRegisterComputerPartitionCall \
SlapLogout \
Tic \
CheckUnexistingComputer \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip('ERP5/Zope does not follow REST API beacuse it is not possible to '
'configure Cookie Crumbler to ignore portal_slap')
def test_slap_registerComputerPartition_draftComputer(self):
"""
Check the slap.registerComputerPartition fails
"""
sequence_list = SequenceList()
sequence_string = '\
LoginTestVifibAdmin \
CreateDraftComputer \
Tic \
Logout \
\
SlapLoginCurrentComputer \
CheckUnauthorizedSlapRegisterComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputerPartition_ComputerWithoutPartition(self):
"""
Check the slap.registerComputerPartition fails
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginCurrentComputer\
CheckNotFoundSlapRegisterComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputerPartition_ComputerWithPartition(self):
"""
Check the slap.registerComputerPartition works
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputerPartition_TwoValidatedComputer(self):
"""
Check the slap.registerComputerPartition works
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerComputerPartition_ComputerWithTwoPartition(self):
"""
Check the slap.registerComputerPartition fails if there are 2 partition
with the same reference.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterComputerPartitionCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapRegisterComputerPartition))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapRegisterSoftwareRelease(TestVifibSlapWebServiceMixin):
########################################
# slap.registerSoftwareRelease
########################################
def test_slap_registerSoftwareRelease_validatedSoftwareRelease(self):
"""
Check the slap.registerSoftwareRelease does not fail if
a validated computer exists.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SlapLoginTestVifibAdmin \
CustomerRegisterNewComputer \
Tic \
SlapLogout \
LoginTestVifibAdmin \
SetComputerCoordinatesFromComputerTitle \
ComputerSetAllocationScopeOpenPublic \
Tic \
Logout \
\
LoginTestVifibDeveloper \
SelectNewSoftwareReleaseUri \
CreateSoftwareRelease \
Tic \
SubmitSoftwareRelease \
Tic \
CreateSoftwareProduct \
Tic \
ValidateSoftwareProduct \
Tic \
SetSoftwareProductToSoftwareRelease \
PublishByActionSoftwareRelease \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerSoftwareRelease_unknowSoftwareReleaseUid(self):
"""
Check the slap.registerSoftwareRelease without any SoftwareRelease document
does not fail
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
SelectNewSoftwareReleaseUri \
\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerSoftwareRelease_draftSoftwareRelease(self):
"""
Check the slap.registerSoftwareRelease does not fail if
a draft computer exits.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
LoginTestVifibDeveloper \
SelectNewSoftwareReleaseUri \
CreateSoftwareRelease \
Tic \
\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_slap_registerSoftwareRelease_TwoValidatedSoftwareRelease(self):
"""
Check the slap.registerSoftwareRelease works
"""
sequence_list = SequenceList()
sequence_string = self.prepare_computer + '\
LoginTestVifibDeveloper \
SelectNewSoftwareReleaseUri \
CreateSoftwareRelease \
Tic \
SubmitSoftwareRelease \
Tic \
CreateSoftwareProduct \
Tic \
ValidateSoftwareProduct \
Tic \
SetSoftwareProductToSoftwareRelease \
PublishByActionSoftwareRelease \
Logout \
\
LoginTestVifibDeveloper \
SelectNewSoftwareReleaseUri \
CreateSoftwareRelease \
Tic \
SubmitSoftwareRelease \
Tic \
CreateSoftwareProduct \
Tic \
ValidateSoftwareProduct \
Tic \
SetSoftwareProductToSoftwareRelease \
PublishByActionSoftwareRelease \
Logout \
\
SlapLoginCurrentComputer \
CheckSuccessSlapRegisterSoftwareReleaseCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapRegisterSoftwareRelease))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapSoftwareReleaseAvailable(TestVifibSlapWebServiceMixin):
########################################
# SoftwareRelease.available
########################################
def test_SoftwareRelease_available_afterRegister(self):
"""
Check that calling SoftwareRelease.available after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
SelectNewSoftwareReleaseUri \
CheckNameErrorSoftwareReleaseAvailableAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapSoftwareReleaseAvailable))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapSoftwareReleaseBuilding(TestVifibSlapWebServiceMixin):
########################################
# SoftwareRelease.building
########################################
def test_SoftwareRelease_building_afterRegister(self):
"""
Check that calling SoftwareRelease.building after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SelectNewSoftwareReleaseUri \
SlapLoginCurrentComputer \
CheckNameErrorSoftwareReleaseBuildingAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapSoftwareReleaseBuilding))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapSoftwareReleaseDestroyed(TestVifibSlapWebServiceMixin):
########################################
# SoftwareRelease.destroyed
########################################
def test_SoftwareRelease_destroyed_afterRegister(self):
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
SelectNewSoftwareReleaseUri \
CheckNameErrorSoftwareReleaseDestroyedAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SoftwareRelease_destroyed_SetupResource_ConfirmedState(self):
sequence_list = SequenceList()
sequence_string = self.prepare_software_release_purchase_packing_list + '\
SlapLoginCurrentComputer \
CheckNotFoundSoftwareReleaseDestroyedCall \
Tic \
SlapLogout \
SlapLoginTestVifibAdmin \
SupplyComputerSoftwareReleaseDestroyed \
Tic \
SlapLogout \
LoginERP5TypeTestCase \
CheckSoftwareReleaseUnavailableForRequest \
CheckSoftwareReleaseNotInSoftwareCatalog \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapSoftwareReleaseDestroyed))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
class TestVifibSlapSoftwareReleaseError(TestVifibSlapWebServiceMixin):
########################################
# SoftwareRelease.error
########################################
def test_SoftwareRelease_error_afterRegister(self):
"""
Check that calling SoftwareRelease.error after just registration raises a
NotFoundError
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + '\
SlapLoginCurrentComputer \
SelectNewSoftwareReleaseUri \
CheckNameErrorSoftwareReleaseErrorAfterRegisterCall \
SlapLogout \
LoginERP5TypeTestCase \
CheckSiteConsistency \
Logout \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapSoftwareReleaseError))
return suite
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from slapos import slap
from slapos.slap.slap import Supply
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
class TestVifibSlapSupply(TestVifibSlapWebServiceMixin):
########################################
# slap.registerSupply
########################################
def test_slap_registerSupply(self):
self.slap = slap.slap()
self.slap.initializeConnection(self.server_url, timeout=None)
supply = self.slap.registerSupply()
self.assertTrue(isinstance(supply, Supply))
########################################
# Supply.supply
########################################
def stepSupplyComputerSoftwareReleaseAvailableRaisesNotImplementedError(self,
sequence, **kw):
# slap not used to raise on server side
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertRaises(NotImplementedError,
computer.requestSoftwareRelease,
software_release_url=sequence['software_release_uri'], state='available')
def stepSupplyComputerSoftwareReleaseDestroyedRaisesNotImplementedError(self,
sequence, **kw):
# slap not used to raise on server side
computer = self.portal.portal_catalog.getResultValue(
uid=sequence['computer_uid'])
self.assertRaises(NotImplementedError,
computer.requestSoftwareRelease,
software_release_url=sequence['software_release_uri'],
state='destroyed')
def test_Supply_supply(self):
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + \
self.prepare_published_software_release + """
SlapLoginCurrentComputer
CheckEmptyComputerGetSoftwareReleaseListCall
SlapLogout
SlapLoginTestVifibAdmin
SupplyComputerSoftwareReleaseAvailable
Tic
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerGetSoftwareReleaseListCall
SlapLogout
SlapLoginTestVifibAdmin
SupplyComputerSoftwareReleaseDestroyed
Tic
SlapLogout
SlapLoginCurrentComputer
CheckDestroyedStateGetSoftwareReleaseListCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def _checkOnePurchasePackingList(self, sequence, resource_uid):
self.assertEqual(1,
self.portal.portal_catalog.countResults(
portal_type='Purchase Packing List Line',
simulation_state='confirmed',
default_resource_uid=resource_uid,
default_aggregate_uid=ComplexQuery(
Query(default_aggregate_uid=sequence['computer_uid']),
Query(default_aggregate_uid=sequence['software_release_uid']),
operator='AND')
)[0][0]
)
def stepCheckOneConfirmedSetupPurchasePackingListLineComputerSoftwareRelease(
self, sequence, **kw):
self._checkOnePurchasePackingList(sequence, self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredSoftwareSetupResource()
).getUid())
def stepCheckOneConfirmedCleanupPurchasePackingListLineComputerSoftwareRelease(
self, sequence, **kw):
self._checkOnePurchasePackingList(sequence, self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredSoftwareCleanupResource()
).getUid())
def test_Supply_supply_twice(self):
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + \
self.prepare_published_software_release + """
SlapLoginCurrentComputer
CheckEmptyComputerGetSoftwareReleaseListCall
SlapLogout
SlapLoginTestVifibAdmin
SupplyComputerSoftwareReleaseAvailable
Tic
SupplyComputerSoftwareReleaseAvailable
Tic
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerGetSoftwareReleaseListCall
SlapLogout
LoginDefaultUser
CheckOneConfirmedSetupPurchasePackingListLineComputerSoftwareRelease
Logout
SlapLoginTestVifibAdmin
SupplyComputerSoftwareReleaseDestroyed
Tic
SupplyComputerSoftwareReleaseDestroyed
Tic
SlapLogout
SlapLoginCurrentComputer
CheckDestroyedStateGetSoftwareReleaseListCall
SlapLogout
LoginDefaultUser
CheckOneConfirmedCleanupPurchasePackingListLineComputerSoftwareRelease
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Supply_lock(self):
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + \
self.prepare_published_software_release + """
SlapLoginCurrentComputer
CheckEmptyComputerGetSoftwareReleaseListCall
SlapLogout
SlapLoginTestVifibAdmin
LoginTestVifibAdmin
SupplyComputerSoftwareReleaseAvailable
SupplyComputerSoftwareReleaseAvailableRaisesNotImplementedError
SupplyComputerSoftwareReleaseDestroyedRaisesNotImplementedError
Tic
SlapLogout
SlapLoginCurrentComputer
CheckSuccessComputerGetSoftwareReleaseListCall
SlapLogout
LoginDefaultUser
CheckOneConfirmedSetupPurchasePackingListLineComputerSoftwareRelease
Logout
SlapLoginTestVifibAdmin
LoginTestVifibAdmin
SupplyComputerSoftwareReleaseDestroyed
SupplyComputerSoftwareReleaseDestroyedRaisesNotImplementedError
SupplyComputerSoftwareReleaseAvailableRaisesNotImplementedError
Tic
SlapLogout
SlapLoginCurrentComputer
CheckDestroyedStateGetSoftwareReleaseListCall
SlapLogout
LoginDefaultUser
CheckOneConfirmedCleanupPurchasePackingListLineComputerSoftwareRelease
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapSupply))
return suite
from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from Products.ERP5Type.tests.Sequence import SequenceList
import unittest
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
class TestVifibSlapWebServiceSlaveInstance(TestVifibSlapWebServiceMixin):
def stepCheckComputerPartitionSaleOrderAggregatedList(self, sequence):
portal_catalog = self.portal.portal_catalog
sale_packing_list = portal_catalog.getResultValue(
uid=sequence['sale_packing_list_uid'])
sale_packing_list_line = sale_packing_list.objectValues()[0]
computer_partition = sale_packing_list_line.getAggregateValue(
portal_type=self.computer_partition_portal_type)
sale_order_line_list = computer_partition.getAggregateRelatedValueList(
portal_type="Sale Order Line")
sale_order_line_1, sale_order_line_2 = sale_order_line_list
self.assertEquals(sale_order_line_1.getAggregateValue(
portal_type=self.computer_partition_portal_type),
sale_order_line_2.getAggregateValue(
portal_type=self.computer_partition_portal_type))
self.assertEquals(2, len(sale_order_line_list))
query = ComplexQuery(
Query(default_aggregate_uid=computer_partition.getUid()),
Query(default_resource_uid=self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredInstanceSetupResource()
).getUid()),
operator="AND"
)
sale_packing_line_list = portal_catalog(
portal_type="Sale Packing List Line",
query=query
)
self.assertEquals(2, len(sale_packing_line_list))
sale_packing_list_line_1, sale_packing_list_line_2 = sale_packing_line_list
self.assertEquals(sale_packing_list_line_1.getAggregateValue(
portal_type=self.software_release_portal_type),
sale_packing_list_line_2.getAggregateValue(
portal_type=self.software_release_portal_type))
self.assertEquals(sale_packing_list_line_1.getAggregateValue(
portal_type=self.computer_partition_portal_type),
sale_packing_list_line_2.getAggregateValue(
portal_type=self.computer_partition_portal_type))
hosting_1, hosting_2 = [hosting.getAggregateValue(
portal_type=self.hosting_subscription_portal_type) \
for hosting in sale_packing_line_list]
self.assertNotEquals(hosting_1, hosting_2)
def test_SlaveInstance_Person_request_with_Different_User(self):
"""
Check that user B can declare a slot of slave instance in computer
partition used by user A
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
SlapLogout
LoginAsCustomerA
PersonRequestSlaveInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Tic # in order to call real build
CheckComputerPartitionSaleOrderAggregatedList
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_request_after_destroy_SlaveInstance(self):
"""
Check that a Slave Instance will not be allocated when a Software
Instance is destroyed
"""
sequence_list = SequenceList()
sequence_string = \
self.prepare_installed_computer_partition_sequence_string + """
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
SlapLogout
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckSlaveInstanceNotReady
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Person_request_SlaveInstance(self):
"""
Check that one Slave Instance is created correctly
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
Logout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
LoginDefaultUser
CheckComputerPartitionSaleOrderAggregatedList
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_getInstanceParameterDict_with_SlaveInstance_stopped(self):
"""
Check that the Slave Instance is ignored when the state of Sale Packing
List in stopped.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + """
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginTestVifibCustomer
SlaveInstanceStarted
Tic
SlaveInstanceStopped
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
SlapLoginCurrentComputer
CheckEmptySlaveInstanceListFromOneComputerPartition
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_getInstanceParameterDict_with_two_SlaveInstance(self):
"""
Check that with two Slave Instance installed in different computers, the
method getInstanceParameterDict returns correctly the slave instance list
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic """ + self.prepare_formated_computer + """
Tic
LoginTestVifibDeveloper \
SelectNewSoftwareReleaseUri \
CreateSoftwareRelease \
Tic \
SubmitSoftwareRelease \
Tic \
CreateSoftwareProduct \
Tic \
ValidateSoftwareProduct \
Tic \
SetSoftwareProductToSoftwareRelease \
PublishByActionSoftwareRelease \
Tic
Logout \
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSoftwareInstance
CleanTic
CallSlaposAllocateInstanceAlarm
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
CheckSlaveInstanceListFromOneComputerPartition
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Person_request_without_SoftwareInstance(self):
"""
Check that one Slave Instance will wait allocation correctly when no
exists Software Instance installed
"""
sequence_list = SequenceList()
sequence_string = self.prepare_formated_computer + \
self.prepare_published_software_release + """
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
CheckSlaveInstanceNotReady
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Person_request_with_Two_Different_ComputerPartition(self):
"""
Check that one Slave Instance is allocated correctly when exists two different
Software Instances and Computer Partition. The slave instance must be
allocated in Computer Partition that exists one Software Instance with
the same Software Release.
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
StoreSoftwareReleaseUri
SetRandomComputerReference
""" + self.prepare_install_requested_computer_partition_sequence_string + """
Tic
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
CheckSlaveInstanceReady
CheckSlaveInstanceAllocationWithTwoDifferentSoftwareInstance
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Person_request_with_Two_Different_SoftwareInstance(self):
"""
Check that one Slave Instance is allocated correctly when exists two different
Software Instances. The slave instance must be allocated in the same
Computer Partition that exists one Software Instance installed.
"""
self.computer_partition_amount = 2
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
StoreSoftwareReleaseUri
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
""" + self.prepare_published_software_release + """
Tic
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSoftwareInstance
CleanTic
CallSlaposAllocateInstanceAlarm
Tic
SelectDifferentSoftwareReleaseUri
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
CallSlaposAllocateInstanceAlarm
Tic
CheckSlaveInstanceAssociationWithSoftwareInstance
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Person_request_twice(self):
"""
Check that request a Slave Instance twice, the instances are created
correctly
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
LoginAsCustomerA
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginTestVifibCustomer
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
CheckTwoSlaveInstanceRequest
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
@skip("Not Implemented yet")
def test_request_SlaveInstance_without_enough_slots(self):
"""
Check the behaviour when one Slave Instance is requested and not exist one
available slot
"""
raise NotImplementedError
def test_SlaveInstance_request_start_from_SoftwareInstance(self):
"""
Check that the Slave Instance will be started correctly when
a Software Instance is started
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
LoginTestVifibCustomer
StartSoftwareInstanceFromCurrentComputerPartition
Tic
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
CheckComputerPartitionInstanceSetupSalePackingListDelivered
LoginTestVifibCustomer
RequestStopSoftwareInstanceFromCurrentComputerPartition
Tic
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
StartSoftwareInstanceFromCurrentComputerPartition
Tic
SoftwareInstanceStarted
Tic
RequestStopSoftwareInstanceFromCurrentComputerPartition
Tic
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
StartSoftwareInstanceFromCurrentComputerPartition
Tic
SoftwareInstanceStarted
Tic
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
LoginTestVifibCustomer
RequestSoftwareInstanceStart
Tic
Logout
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
SetDeliveryLineAmountEqualOne
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
RequestStopSoftwareInstanceFromCurrentComputerPartition
Tic
SlapLoginCurrentComputer
SoftwareInstanceStopped
Tic
LoginTestVifibCustomer
StartSoftwareInstanceFromCurrentComputerPartition
Tic
SlapLoginCurrentComputer
SoftwareInstanceStarted
Tic
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_request_stop(self):
"""
Check that the Slave Instance will be stopped correctly
"""
sequence_list = SequenceList()
sequence_string = self.prepare_started_computer_partition_sequence_string + """
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
CheckSuccessComputerGetComputerPartitionCall
SoftwareInstanceStarted
Tic
SlapLogout
LoginTestVifibCustomer
RequestSoftwareInstanceStop
Tic
Logout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SoftwareInstanceStarted
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceHostingSalePackingListStopped
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepCheckComputerPartitionIsBusy(self, sequence, **kw):
computer_partition_uid = sequence["computer_partition_uid"]
computer_partition = self.portal.portal_catalog.getResultValue(
uid=computer_partition_uid)
self.assertEqual('busy', computer_partition.getSlapState())
def test_SlaveInstance_request_destroy(self):
"""
Check that the Slave Instance will be destroyed correctly
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
LoginTestVifibCustomer
RequestSoftwareInstanceDestroy
Tic
SlapLogout
LoginDefaultUser
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
CheckComputerPartitionIsBusy
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_check_permission_with_different_customer(self):
"""
Check that one Customer A can not view the Slave Instance of a Customer B
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginAsCustomerA
CheckSlaveInstanceSecurityWithDifferentCustomer
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLogout
LoginTestVifibCustomer
CheckSlaveInstanceSecurityWithDifferentCustomer
Tic
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_Information_with_getInstanceParameterDict(self):
"""
Check that Computer Partition of user A is reinstanciated with new
parameters provided by user B. User B and Aget the right connection
parameter
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
CheckEmptySlaveInstanceListFromOneComputerPartition
LoginAsCustomerA
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_security_with_SoftwareInstance_user(self):
"""
Check that the software instance user can access a Slave Instance
installed in the same computer partition than your software instance
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
CheckEmptySlaveInstanceListFromOneComputerPartition
LoginTestVifibCustomer
SetSoftwareTitleRandom
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
StoreSalePackingListLineFromSlaveInstance
StoreSaleOrderFromSlaveInstance
SlapLoginCurrentComputer
CheckSlaveInstanceListFromOneComputerPartition
SlapLoginSoftwareInstanceFromCurrentSoftwareInstance
CheckSlaveInstanceAccessUsingCurrentSoftwareInstanceUser
CheckSalePackingListFromSlaveInstanceAccessUsingSoftwareInstanceUser
CheckSaleOrderFromSlaveInstanceAccessUsingSoftwareInstanceUser
CheckHostingSubscriptionFromSlaveInstanceAccessUsingSoftwareInstanceUser
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_SlaveInstance_update_connection_xml(self):
"""
Check that the connection_xml will be update correctly using portal_slap
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
CheckEmptySlaveInstanceListFromOneComputerPartition
LoginAsCustomerA
PersonRequestSlaveInstance
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SlapLoginSoftwareInstanceFromCurrentSoftwareInstance
SetConnectionXmlToSlaveInstance
CheckConnectionXmlFromSlaveInstance
CheckConnectionXmlFromSoftwareInstance
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetSoftwareInstanceAsCurrentRequestedSlave(self, sequence, **kw):
slave_instance = self.portal.portal_catalog.getResultValue(
uid=sequence['software_instance_uid']).getPredecessorValue(
portal_type='Slave Instance')
sequence['software_instance_uid'] = slave_instance.getUid()
def stepCheckComputerPartitionInstanceUpdateSalePackingListDelivered(self,
sequence, **kw):
self._checkComputerPartitionSalePackingListState('delivered',
self.portal.portal_preferences.getPreferredInstanceUpdateResource(),
sequence)
def test_SlaveInstance_change_parameter_dict_after_request(self):
"""
Check that request to change the parameter dict from a Slave Instance
will create update packing list correctly
"""
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
CheckEmptySlaveInstanceListFromOneComputerPartition
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
SlapLoginCurrentComputer
LoginDefaultUser
StartSoftwareInstanceFromCurrentComputerPartition
Tic
Logout
SlapLoginCurrentSoftwareInstance
SoftwareInstanceStarted
Tic
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
SlapLoginCurrentSoftwareInstance
SelectRequestedParameterDictRequestedParameter
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
SetSoftwareInstanceAsCurrentRequestedSlave
CheckComputerPartitionInstanceUpdateSalePackingListDelivered
Logout
SlapLoginCurrentComputer
CheckSuccessComputerGetComputerPartitionCall
SlapLogout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_Security_after_destroy_SoftwareInstance_with_different_user(self):
"""
Check that destroying one Software Instance it will not destroy Slave
Instances that is not related to your Software Instance.
Scenario:
VifibCustomer CustomerA
| |
SoftwareInstance SoftwareInstanceA (requestDestroy)
| |
SlaveInstance SlaveInstanceA
The Slave Instance related to Customer should not be destroyed
"""
self.computer_partition_amount = 4
sequence_list = SequenceList()
sequence_string = self.prepare_install_requested_computer_partition_sequence_string + """
Tic
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
CheckEmptySlaveInstanceListFromOneComputerPartition
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed """ + \
self.prepare_published_software_release + """
Tic
LoginTestVifibAdmin
RequestSoftwareInstallation
Tic
Logout
SlapLoginCurrentComputer
ComputerSoftwareReleaseAvailable
Tic
SlapLogout
LoginAsCustomerA
PersonRequestSoftwareInstance
Logout
Tic
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
SetSelectedComputerPartition
SelectCurrentlyUsedSalePackingListUid
Logout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLoginCurrentSoftwareInstance
SelectEmptyRequestedParameterDict
SetRandomRequestedReference
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
LoginDefaultUser
CallSlaposAllocateInstanceAlarm
Tic
Logout
SlapLoginCurrentSoftwareInstance
RequestSlaveInstanceFromComputerPartition
Tic
SlapLogout
SlapLoginCurrentComputer
SoftwareInstanceAvailable
Tic
SlapLogout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceSetupSalePackingListDelivered
CheckComputerPartitionInstanceHostingSalePackingListConfirmed
Logout
LoginAsCustomerA
RequestDestroySoftwareInstanceFromCurrentComputerPartition
Tic
Logout
LoginDefaultUser
SetDeliveryLineAmountEqualOne
CheckComputerPartitionInstanceCleanupSalePackingListConfirmed
Logout
LoginERP5TypeTestCase
CheckSiteConsistency
Logout
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSlapWebServiceSlaveInstance))
return suite
from Products.ERP5Type.tests.backportUnittest import skip
import unittest
from VifibMixin import testVifibMixin
class TestVifibSoftwareInstance(testVifibMixin):
########################################
# Software Instance graph helpers
########################################
def _test_si_tree(self):
software_instance = self.portal.software_instance_module.newContent(
portal_type='Software Instance')
self.markManualCreation(software_instance)
self.checkConnected = software_instance.checkConnected
self.checkNotCyclic = software_instance.checkNotCyclic
def test_si_tree_simple_connected(self):
"""Graph of one element is connected
A
"""
self._test_si_tree()
graph = {'A': []}
root = 'A'
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_simple_list_connected(self):
"""Graph of list is connected
B->C->A
"""
self._test_si_tree()
graph = {'A': [], 'B': ['C'], 'C': ['A']}
root = 'B'
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_complex_connected(self):
"""Tree is connected
B --> A
\-> C --> D
\-> E --> F
"""
self._test_si_tree()
graph = {
'A': [],
'B': ['A', 'C'],
'C': ['D', 'E'],
'D': [],
'E': ['F'],
'F': [],
}
root = 'B'
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_simple_list_disconnected(self):
"""Two lists are disconnected
A->B
C
"""
self._test_si_tree()
graph = {'A': ['B'], 'B': [], 'C': []}
root = 'A'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root)
@skip('For now limitation of implementation gives false positive')
def test_si_tree_cyclic_connected(self):
"""Cyclic is connected
A<->B
"""
self._test_si_tree()
graph = {'A': ['B'], 'B': ['A']}
root = 'B'
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_cyclic_disconnected(self):
"""Two trees, where one is cyclic are disconnected
B --> A
\-> H
C --> D --> G
^ \-> E --> F \
\------------/
"""
self._test_si_tree()
graph = {
'A': [],
'B': ['A', 'H'],
'C': ['D', 'E'],
'D': ['G'],
'E': ['F'],
'F': ['C'],
'G': [],
'H': [],
}
root = 'B'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root)
def test_si_tree_simple_not_cyclic(self):
"""Graph of one element is not cyclic
A
"""
self._test_si_tree()
graph = {'A': []}
self.assertEqual(True, self.checkNotCyclic(graph))
def test_si_tree_simple_list_not_cyclic(self):
"""Graph of list is not cyclic
B->C->A
"""
self._test_si_tree()
graph = {'A': [], 'B': ['C'], 'C': ['A']}
self.assertEqual(True, self.checkNotCyclic(graph))
def test_si_tree_simple_list_cyclic(self):
"""Graph of cyclic list is cyclic
B->C->A-\
^-------/
"""
self._test_si_tree()
graph = {'A': ['B'], 'B': ['C'], 'C': ['A']}
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree, self.checkNotCyclic, graph)
def test_si_tree_simple_list_cyclic_non_root(self):
"""Graph of cyclic list is cyclic
B->C->D->A-\
^-------/
"""
self._test_si_tree()
graph = {'A': ['C'], 'B': ['C'], 'C': ['D'], 'D': ['A']}
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree, self.checkNotCyclic, graph)
def test_si_tree_complex_not_cyclic(self):
"""Tree is not cyclic
B --> A
\-> C --> D
\-> E --> F
"""
self._test_si_tree()
graph = {
'A': [],
'B': ['A', 'C'],
'C': ['D', 'E'],
'D': [],
'E': ['F'],
'F': [],
}
self.assertEqual(True, self.checkNotCyclic(graph))
def test_si_tree_complex_cyclic(self):
"""Tree is not cyclic
B --> A
\-> C --> D
^ \-> E --> F -\
\-------------/
"""
self._test_si_tree()
graph = {
'A': [],
'B': ['A', 'C'],
'C': ['D', 'E'],
'D': [],
'E': ['F'],
'F': ['C'],
}
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree, self.checkNotCyclic, graph)
def test_si_tree_simple_list_disconnected_not_cyclic(self):
"""Two lists are disconnected
A->B
C
"""
self._test_si_tree()
graph = {'A': ['B'], 'B': [], 'C': []}
self.assertEqual(True, self.checkNotCyclic(graph))
def test_si_tree_cyclic(self):
"""Cyclic is connected
A<->B
"""
self._test_si_tree()
graph = {'A': ['B'], 'B': ['A']}
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree, self.checkNotCyclic, graph)
def test_si_tree_cyclic_disconnected_cyclic(self):
"""Two trees, where one is cyclic are disconnected
B --> A
\-> H
C --> D --> G
^ \-> E --> F \
\------------/
"""
self._test_si_tree()
graph = {
'A': [],
'B': ['A', 'H'],
'C': ['D', 'E'],
'D': ['G'],
'E': ['F'],
'F': ['C'],
'G': [],
'H': ['A'],
}
from erp5.document.SoftwareInstance import CyclicSoftwareTree
self.assertRaises(CyclicSoftwareTree, self.checkNotCyclic, graph)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibSoftwareInstance))
return suite
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from VifibMixin import testVifibMixin
import transaction
import unittest
class TestVifibUpgrader(testVifibMixin):
""" Checks that Vifib Upgrader is callable. """
def test_simple_call(self):
self.login()
portal = self.getPortalObject()
portal.portal_alarms.upgrader_controller.activeSense()
transaction.commit()
self.tic()
self.assertEqual(1,
self.portal.portal_alarms.accept_submitted_credentials.isEnabled())
self.assertEqual(1,
self.portal.portal_alarms.slapos_allocate_instance.isEnabled())
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibUpgrader))
return suite
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import unittest
from VifibMixin import testVifibMixin
HTTP_OK = 200
MOVED_TEMPORARILY = 302
class TestVifibWebSite(testVifibMixin):
web_site_portal_type = "Web Site"
auth = 'ERP5TypeTestCase:'
def getTitle(self):
return "Vifib WebSite"
def test_01_checkERP5Access(self):
"""
Test default ERP5 page
"""
response = self.publish('/%s' % \
self.portal.getId(), self.auth)
self.assertEquals(HTTP_OK, response.getStatus())
self.assertTrue(response.getHeader('content-type').startswith('text/html'))
self.assertTrue("Welcome to ERP5" in response.getBody())
def test_02_checkCashCloudAccess(self):
"""
Test Cash access
"""
module = self.portal.getDefaultModule(self.web_site_portal_type)
web_site = getattr(module, 'cash')
#Check web site is present
self.assertTrue(web_site is not None, "Website not found")
# Test anonymous
response = self.publish('/%s/%s' % \
(self.portal.getId(), web_site.getRelativeUrl())
)
self.assertEquals(HTTP_OK, response.getStatus())
self.assertEquals('text/html; charset=utf-8',
response.getHeader('content-type'))
self.assertTrue("Website is under construction..." in response.getBody())
def test_04_checkHostingAccess(self):
"""
Test Hosting Access
"""
module = self.portal.getDefaultModule(self.web_site_portal_type)
web_site = getattr(module, 'hosting')
#Check web site is present
self.assertTrue(web_site is not None, "Website not found")
# Test anonymous
response = self.publish('/%s/%s' % \
(self.portal.getId(), web_site.getRelativeUrl())
)
self.assertEquals(HTTP_OK, response.getStatus())
self.assertEquals('text/html; charset=utf-8',
response.getHeader('content-type'))
self.assertTrue("Enjoy Decentralized Cloud&nbsp;Computing" in response.getBody())
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibWebSite))
return suite
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Nicolas Delaby <nicolas@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import unittest
from VifibMixin import testVifibMixin
from Products.ERP5Type.tests.backportUnittest import skip
class TestVifibXHTML(testVifibMixin):
run_all_test = 1
def getTitle(self):
return "Vifib XHTML"
def changeSkin(self, skin_name):
"""
Change current Skin
"""
request = self.app.REQUEST
self.getPortal().portal_skins.changeSkin(skin_name)
request.set('portal_skin', skin_name)
def test_deadProxyFields(self):
# check that all proxy fields defined in business templates have a valid
# target
skins_tool = self.portal.portal_skins
error_list = []
for skin_name, skin_folder_string in skins_tool.getSkinPaths():
skin_folder_id_list = skin_folder_string.split(',')
self.changeSkin(skin_name)
for skin_folder_id in skin_folder_id_list:
for field_path, field in skins_tool[skin_folder_id].ZopeFind(
skins_tool[skin_folder_id],
obj_metatypes=['ProxyField'], search_sub=1):
template_field = field.getTemplateField(cache=False)
if template_field is None:
# Base_viewRelatedObjectList (used for proxy listbox ids on
# relation fields) is an exception, the proxy field has no target
# by default.
if field_path != 'Base_viewRelatedObjectList/listbox':
error_list.append((skin_name, field_path, field.get_value('form_id'),
field.get_value('field_id')))
if error_list:
message = '\nDead proxy field list\n'
for error in error_list:
message += '\t%s\n' % str(error)
self.fail(message)
def test_emptySelectionNameInListbox(self):
# check all empty selection name in listboxes
skins_tool = self.portal.portal_skins
error_list = []
for form_path, form in skins_tool.ZopeFind(
skins_tool, obj_metatypes=['ERP5 Form'], search_sub=1):
try:
fields = form.get_fields()
except AttributeError, e:
print "%s is broken: %s" % (form_path, e)
for field in fields:
if field.meta_type =='ListBox':
selection_name = field.get_value("selection_name")
if selection_name in ("",None):
error_list.append(form_path)
self.assertEquals(error_list, [])
def test_callableListMethodInListbox(self):
# check all list_method in listboxes
skins_tool = self.portal.portal_skins
error_list = []
for form_path, form in skins_tool.ZopeFind(
skins_tool, obj_metatypes=['ERP5 Form'], search_sub=1):
try:
fields = form.get_fields()
except AttributeError, e:
print "%s is broken: %s" % (form_path, e)
for field in fields:
if field.meta_type == 'ListBox':
list_method = field.get_value("list_method")
if list_method:
if isinstance(list_method, str):
method = getattr(self.portal, list_method)
else:
method = list_method
if not callable(method):
error_list.append(form_path)
self.assertEquals(error_list, [])
@skip('Skipped.')
def test_configurationOfFieldLibrary(self):
self.login()
error_list = []
for business_template in self.portal.portal_templates.searchFolder(
title='vifib_%'):
# XXX Impossible to filter by installation state, as it is not catalogued
business_template = business_template.getObject()
for modifiable_field in business_template.BusinessTemplate_getModifiableFieldList():
# Do not consider 'Check delegated values' as an error
if modifiable_field.choice_item_list[0][1] != \
"0_check_delegated_value":
error_list.append((business_template.getTitle(),
modifiable_field.object_id,
modifiable_field.choice_item_list[0][0]))
if error_list:
message = '%s fields to modify' % len(error_list)
message += '\n\t' + '\n\t'.join(bt_title + ':' + fieldname + ": " + \
message for bt_title, fieldname, message in error_list)
self.fail(message)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestVifibXHTML))
return suite
...@@ -14,17 +14,6 @@ slapos_bt_list = [ ...@@ -14,17 +14,6 @@ slapos_bt_list = [
'slapos_payzen', 'slapos_payzen',
] ]
class VIFIB(SavedTestSuite, ProjectTestSuite):
_product_list = ['Vifib']
_saved_test_id = 'Products.Vifib.tests.VifibMixin.testVifibMixin'
_bt_list = slapos_bt_list + [
'vifib_base',
'vifib_data',
'vifib_erp5',
'vifib_slap',
'vifib_upgrader',
]
class SlapOSCloud(SavedTestSuite, ProjectTestSuite): class SlapOSCloud(SavedTestSuite, ProjectTestSuite):
_product_list = ['SlapOS'] _product_list = ['SlapOS']
_saved_test_id = 'Products.SlapOS.tests.testSlapOSMixin.testSlapOSMixin' _saved_test_id = 'Products.SlapOS.tests.testSlapOSMixin.testSlapOSMixin'
......
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