Commit 3cfd4565 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Update tests for updating Business Manager

parent 4301bf87
...@@ -71,6 +71,9 @@ class TestBusinessPackage(ERP5TypeTestCase): ...@@ -71,6 +71,9 @@ class TestBusinessPackage(ERP5TypeTestCase):
self.export_dir = '' self.export_dir = ''
self.portal = self.getPortalObject() self.portal = self.getPortalObject()
# create dummy portal_type to be used in current live test
#self.portal.portal_type('')
def beforeTearDown(self): def beforeTearDown(self):
try: try:
package_id = self.package.getId() package_id = self.package.getId()
...@@ -131,7 +134,9 @@ class TestBusinessPackage(ERP5TypeTestCase): ...@@ -131,7 +134,9 @@ class TestBusinessPackage(ERP5TypeTestCase):
bm_id = 'manager_%s'%str(time.time()) bm_id = 'manager_%s'%str(time.time())
if not title: if not title:
title = bm_id title = bm_id
manager = self.portal.portal_templates.newContent(id=bm_id, \ manager = self.portal.portal_templates.newContent(
id=bm_id,
title=title,
portal_type='Business Manager') portal_type='Business Manager')
self.tic() self.tic()
return manager return manager
...@@ -273,46 +278,48 @@ class TestBusinessPackage(ERP5TypeTestCase): ...@@ -273,46 +278,48 @@ class TestBusinessPackage(ERP5TypeTestCase):
managerA = self._createBusinessManager() managerA = self._createBusinessManager()
managerB = self._createBusinessManager() managerB = self._createBusinessManager()
test_catalog = self.portal.portal_catalog.newContent( test_folder = self.portal.newContent(
portal_type = 'Catalog', id='test_folder',
title = 'Test Catalog initial for Multiple BM Installation', portal_type='Folder',
title='couscous',
) )
# Add catalog to the path list for Business Manager and build the object # Add catalog to the path list for Business Manager and build the object
catalog_path = test_catalog.getRelativeUrl() folder_path = test_folder.getRelativeUrl()
path_item_catalog = '%s | %s | %s' % (catalog_path, 1, 1) path_item_folder = '%s | %s | %s' % (folder_path, 1, 1)
path_item_list = [path_item_catalog] path_item_list = [path_item_folder]
# Set catalog path item as path_item in managerB # Set catalog path item as path_item in managerB
managerB._setTemplatePathList(path_item_list) managerB._setTemplatePathList(path_item_list)
# Build both Business Manager(s) copy_data = portal_templates.manage_copyObjects(ids=[
built_manager_A = managerA.build() managerA.id,
built_manager_B = managerB.build() managerB.id,
])
result = portal_templates.manage_pasteObjects(copy_data)
managerA_new_id = result[0]['new_id']
managerB_new_id = result[1]['new_id']
# Delete the catalog object managerA_new = portal_templates._getOb(managerA_new_id)
self.portal.portal_catalog.manage_delObjects( managerB_new = portal_templates._getOb(managerB_new_id)
[test_catalog.getId(),])
# Test that the catalog don't exist on site anymore managerA_new.build()
self.assertRaises(KeyError, lambda: self.portal.restrictedTraverse(catalog_path)) managerB_new.build()
# Change the status of the new Business Manager objects as combined
# installation checks if the Business Manager has status 'uninstalled'
managerA_new.setStatus('uninstalled')
managerB_new.setStatus('uninstalled')
# Export the built Business Manager # Delete the catalog object
exported_manager_path_B = self._exportBusinessManager(built_manager_A) self.portal.manage_delObjects([test_folder.getId(),])
exported_manager_path_A = self._exportBusinessManager(built_manager_B)
# Import the Business Managers # Test that the catalog don't exist on site anymore
imported_manager_A = self._importBusinessManager(managerA, self.assertRaises(KeyError, lambda: self.portal.restrictedTraverse(folder_path))
exported_manager_path_A,
increment=1)
imported_manager_B = self._importBusinessManager(managerB,
exported_manager_path_B,
increment=1)
# Install both the Business Manager(s) # Install both the Business Manager(s)
portal_templates.installMultipleBusinessManager([ portal_templates.installMultipleBusinessManager([
imported_manager_A, managerA_new,
imported_manager_B, managerB_new,
]) ])
# XXX: Match the state of manager A and B, nothing extra added # XXX: Match the state of manager A and B, nothing extra added
...@@ -322,46 +329,57 @@ class TestBusinessPackage(ERP5TypeTestCase): ...@@ -322,46 +329,57 @@ class TestBusinessPackage(ERP5TypeTestCase):
# ]) # ])
# Test that the catalog exists on ZODB after installation # Test that the catalog exists on ZODB after installation
installed_test_catalog = self.portal.restrictedTraverse(catalog_path) installed_test_folder = self.portal.restrictedTraverse(folder_path)
self.assertEquals(installed_test_catalog.getTitle(), \ self.assertEquals(installed_test_folder.getTitle(),
'Test Catalog initial for Multiple BM Installation') 'couscous')
# Add catalog_path to managerA and remove the catalog_path from managerB # Add catalog_path to managerA and remove the catalog_path from managerB
managerA._setTemplatePathList(path_item_list) managerA._setTemplatePathList(path_item_list)
managerB._setTemplatePathList([]) managerB._setTemplatePathList([])
installed_test_catalog.edit(title='new_couscous') copy_data = portal_templates.manage_copyObjects(ids=[
managerA.id,
managerB.id,
])
result = portal_templates.manage_pasteObjects(copy_data)
managerA_new_id = result[0]['new_id']
managerB_new_id = result[1]['new_id']
# Build both the Business Manager(s) managerA_new = portal_templates._getOb(managerA_new_id)
built_manager_A = managerA.build() managerB_new = portal_templates._getOb(managerB_new_id)
built_manager_B = managerB.build()
# Then we change the title of test catalog again installed_test_folder.edit(title='new_couscous')
installed_test_catalog.edit(title='new_couscous_change_again')
# Build the new managers so that they do have the Business Item(s) defined
# in them properly
managerA_new.build()
managerB_new.build()
# Export the built Business Manager # Change the status of the new Business Manager objects as combined
exported_manager_path_A = self._exportBusinessManager(built_manager_A) # installation checks if the Business Manager has status 'uninstalled'
exported_manager_path_B = self._exportBusinessManager(built_manager_B) managerA_new.setStatus('uninstalled')
managerB_new.setStatus('uninstalled')
# Import the Business Managers # Then we change the title of test catalog again
imported_manager_A = self._importBusinessManager(managerA, installed_test_folder.edit(title='new_couscous_change_again')
exported_manager_path_A,
increment=2)
imported_manager_B = self._importBusinessManager(managerB,
exported_manager_path_B,
increment=2)
# Match the overall state, # Match the overall state,
# Install both the Business Manager(s) # Install both the Business Manager(s)
portal_templates.installMultipleBusinessManager([ portal_templates.installMultipleBusinessManager([
imported_manager_A, managerA_new,
imported_manager_B, managerB_new,
]) ])
# Test that the catalog exists on ZODB after installation with the newer # Test that the catalog exists on ZODB after installation with the newer
# updated version # updated version
catalog = self.portal.restrictedTraverse(installed_test_catalog.getRelativeUrl()) test_folder = self.portal.restrictedTraverse(installed_test_folder.getRelativeUrl())
self.assertEquals(catalog.getTitle(), "new_couscous") self.assertEquals(test_folder.getTitle(), "new_couscous")
# Delete the test folder created at the path if it exists there
try:
self.portal.manage_delObjects([test_folder.getId(),])
except Exception:
pass
def _UpdateVersionOfBusinessManager(self): def _UpdateVersionOfBusinessManager(self):
""" """
......
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