testBusinessTemplate.py 101 KB
Newer Older
1 2
##############################################################################
#
Aurel's avatar
Aurel committed
3 4
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
#          Aurelien Calonne <aurel@nexedi.com>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability 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
# garantees and support are strongly adviced 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 random import randint

import os, sys
if __name__ == '__main__':
Aurel's avatar
Aurel committed
33
  execfile(os.path.join(sys.path[0], 'framework.py'))
34 35 36 37 38 39 40

# Needed in order to have a log file inside the current folder
os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
os.environ['EVENT_LOG_SEVERITY'] = '-300'

from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
Aurel's avatar
Aurel committed
41 42
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_base
43 44
from zLOG import LOG
from Products.ERP5Type.ERP5Type import ERP5TypeInformation
45
from App.config import getConfiguration
Aurel's avatar
Aurel committed
46
from Products.ERP5Type.tests.Sequence import SequenceList
Aurel's avatar
Aurel committed
47
from urllib import pathname2url
Aurel's avatar
Aurel committed
48 49 50
from Globals import PersistentMapping
from Products.CMFCore.Expression import Expression
import os
51 52 53 54 55 56 57 58 59 60 61 62 63

class TestBusinessTemplate(ERP5TypeTestCase):
  """
    Test these operations:

    - Create a template

    - Install a template

    - Uninstall a template

    - Upgrade a template
  """
Romain Courteaud's avatar
Romain Courteaud committed
64
  run_all_test = 1
Yoshinori Okuji's avatar
Yoshinori Okuji committed
65 66 67
  
  def getTitle(self):
    return "Business Template"
68

Romain Courteaud's avatar
Romain Courteaud committed
69 70 71 72 73 74 75
  def enableActivityTool(self):
    """
    You can override this.
    Return if we should create (1) or not (0) an activity tool.
    """
    return 1

76 77 78 79 80 81 82 83 84 85 86
  def afterSetUp(self):
    self.login()
    portal = self.getPortal()
    catalog_tool = self.getCatalogTool()

  def login(self):
    uf = self.getPortal().acl_users
    uf._doAddUser('seb', '', ['Manager'], [])
    user = uf.getUserById('seb').__of__(uf)
    newSecurityManager(None, user)

Aurel's avatar
Aurel committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  def stepTic(self,**kw):
    self.tic()

  def stepCommitTransaction(self, **kw):
    get_transaction().commit()

  def stepUseCoreBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Define erp5_core as current bt
    """
    template_tool = self.getTemplateTool()
    core_bt = None
    for bt in template_tool.objectValues(filter={'portal_type':'Business Template'}):
      if bt.getTitle() == 'erp5_core':
        core_bt = bt
        break
    self.failIf(core_bt is None)
    sequence.edit(current_bt=core_bt)

Aurel's avatar
Aurel committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

  def stepCopyCoreBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Copy erp5_core as new Business Template
    """
    template_tool = self.getTemplateTool()
    core_bt = None
    for bt in template_tool.objectValues(filter={'portal_type':'Business Template'}):
      if bt.getTitle() == 'erp5_core':
        core_bt = bt
        break
    self.failIf(core_bt is None)
    # make copy
    copy_data = template_tool.manage_copyObjects(ids=[core_bt.getId()])
    ids = template_tool.manage_pasteObjects(copy_data)
    new_id = ids[0]['new_id']
    new_bt = template_tool._getOb(new_id)
    self.assertEqual(new_bt.getTitle(), 'erp5_core')
    sequence.edit(copy_bt=new_bt)

  def stepUseCopyCoreBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Define erp5_core as current bt
    """
    bt = sequence.get('copy_bt')
    sequence.edit(current_bt=bt, export_bt=bt)

Aurel's avatar
Aurel committed
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
  def stepUseExportBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Define export_bt as current bt
    """
    bt = sequence.get('export_bt')
    sequence.edit(current_bt=bt)

  def stepUseImportBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Define import_bt as current bt
    """
    bt = sequence.get('import_bt')
    sequence.edit(current_bt=bt)
    
  def stepCheckInstalledInstallationState(self, sequence=None,
                                        seqeunce_list=None, **kw):
    """
    Check if installation state is installed
    """
    bt = sequence.get('current_bt', None)
    self.assertEquals(bt.getInstallationState(), 'installed')

  def stepCheckNotInstalledInstallationState(self, sequence=None,
                                        seqeunce_list=None, **kw):
    """
    Check if installation state is not_installed
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getInstallationState(), 'not_installed')

  def stepCheckReplacedInstallationState(self, sequence=None,
                                        seqeunce_list=None, **kw):
    """
    Check if installation state is replaced
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getInstallationState(), 'replaced')

  def stepCheckModifiedBuildingState(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
    Check if the building state is modified.
180
    """
Aurel's avatar
Aurel committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getBuildingState(), 'modified')

  def stepCheckBuiltBuildingState(self, sequence=None, 
                                  sequence_list=None, **kw):
    """
    Check if the building state is built.
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getBuildingState(), 'built')

  def stepCheckTools(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of tools
    """
    self.failUnless(self.getCategoryTool() is not None)
    self.failUnless(self.getTemplateTool() is not None)
    self.failUnless(self.getTypeTool() is not None)
    self.failUnless(self.getSkinsTool() is not None)
    self.failUnless(self.getCatalogTool() is not None)
    self.failUnless(self.getTrashTool() is not None)    
    
  def stepCheckSkinsLayers(self, sequence=None, sequence_list=None, **kw):
    """
    Check skins layers
    """
    skins_tool = self.getSkinsTool()
    for skin_name, selection in skins_tool.getSkinPaths():
      if skin_name == 'View':
        self.failIf('erp5_pdf_style' in selection)
        self.failIf('erp5_csv_style' in selection)
        self.failIf('erp5_core' not in selection)
        self.failIf('erp5_html_style' not in selection)
      if skin_name == 'Print':
        self.failIf('erp5_html_style' in selection)
        self.failIf('erp5_csv_style' in selection)
        self.failIf('erp5_core' not in selection)
        self.failIf('erp5_pdf_style' not in selection)
      if skin_name == 'CSV':
        self.failIf('erp5_pdf_style' in selection)
        self.failIf('erp5_html_style' in selection)
        self.failIf('erp5_core' not in selection)
        self.failIf('erp5_csv_style' not in selection)

  def stepCheckNoTrashBin(self, sequence=None, sequence_list=None, **kw):
    """
    Check if there is no trash bins
    """
    trash = self.getTrashTool()
    self.assertEquals(len(trash.objectIds()), 0)

  def stepRemoveAllTrashBins(self, sequence=None, sequence_list=None, **kw):
    """
    Remove all trash bins
    """
    trash = self.getTrashTool()
    trash_ids = list(trash.objectIds())
    for id in trash_ids:
      trash.deleteContent(id)
    self.failIf(len(trash.objectIds()) > 0)

  def stepCheckTrashBin(self, sequence=None, sequence_list=None, **kw):
    """
    Check trash bin presence
    """
    trash = self.getTrashTool()
    trash_ids = list(trash.objectIds())
    self.assertEquals(len(trash.objectIds()), 1)
    bt_id = sequence.get('import_bt').getId()
    self.failUnless(bt_id not in trash_ids[0])

  # portal types
  def stepCreatePortalType(self, sequence=None, sequence_list=None, **kw):
    """
    Create Portal Type
256 257
    """
    pt = self.getTypeTool()
Aurel's avatar
Aurel committed
258 259 260 261 262 263
    # create module object portal type
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type, id='Geek Object', typeinfo_name='ERP5Type: ERP5 Person')
    object_type = pt._getOb('Geek Object', None)
    self.failUnless(object_type is not None)
    sequence.edit(object_ptype_id=object_type.getId())
    # create module portal type
264 265 266
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type, id='Geek Module', typeinfo_name='ERP5Type: ERP5 Folder')
    module_type = pt._getOb('Geek Module', None)
    self.failUnless(module_type is not None)
Aurel's avatar
Aurel committed
267
    module_type.filter_content_types = 1
Aurel's avatar
Aurel committed
268 269 270 271 272 273 274 275 276 277 278 279
    module_type.allowed_content_types = ('Geek Object',)
    sequence.edit(module_ptype_id=module_type.getId())

  def stepAddPortalTypeToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add types to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    ptype_ids = []
    ptype_ids.append(sequence.get('object_ptype_id', ''))
    ptype_ids.append(sequence.get('module_ptype_id', ''))
Aurel's avatar
Aurel committed
280
    self.assertEqual(len(ptype_ids), 2)    
Aurel's avatar
Aurel committed
281
    bt.edit(template_portal_type_id_list=ptype_ids)
Aurel's avatar
Aurel committed
282
    self.stepFillPortalTypesFields(sequence=sequence, sequence_list=sequence_list, **kw)
Aurel's avatar
Aurel committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
    
  def stepRemovePortalType(self, sequence=None, sequence_list=None, **kw):
    """
    Remove PortalType    
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    module_id = sequence.get('module_ptype_id')
    pt.manage_delObjects([module_id, object_id])
    module_type = pt._getOb(module_id, None)
    self.failUnless(module_type is None)
    object_type = pt._getOb(object_id, None)
    self.failUnless(object_type is None)

  def stepCheckPortalTypeExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of portal type
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    module_id = sequence.get('module_ptype_id')
    module_type = pt._getOb(module_id, None)
    self.failUnless(module_type is not None)
    object_type = pt._getOb(object_id, None)
307
    self.failUnless(object_type is not None)
Aurel's avatar
Aurel committed
308 309 310 311 312 313 314 315 316 317 318 319
    
  def stepCheckPortalTypeRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of portal type
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    module_id = sequence.get('module_ptype_id')
    module_type = pt._getOb(module_id, None)
    self.failUnless(module_type is None)
    object_type = pt._getOb(object_id, None)
    self.failUnless(object_type is None)
320

Aurel's avatar
Aurel committed
321 322 323 324 325 326 327 328
  def stepFillPortalTypesFields(self, sequence=None, sequence_list=None, **kw):
    """
    Fill portal types properties field in business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.getPortalTypesProperties()

Aurel's avatar
Aurel committed
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
  # module
  def stepCreateModuleAndObjects(self, sequence=None, sequence_list=None, **kw):
    """
    Create Module with objects
    """
    portal = self.getPortal()
    id = 'geek_module'
    n = 0
    while id in portal.objectIds():
      n = n + 1
      id = "%s_%s" %('geek_module', n)      
    module = portal.newContent(id=id, portal_type='Geek Module')
    self.failUnless(module is not None)
    sequence.edit(module_id=module.getId())
    module_object_list = []
    for i in xrange(10):
      object = module.newContent(portal_type = 'Geek Object')
      self.failUnless(object is not None)
      module_object_list.append(object)
    sequence.edit(module_object_id_list=module_object_list)

  def stepAddModuleToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add module to business template
    """
    bt = sequence.get('current_bt', None)
    module_id = sequence.get('module_id', None)
    self.failUnless(module_id is not None)
    bt.edit(template_module_id_list=[module_id])

  def stepCreateModuleObjects(self, sequence=None, sequence_list=None, **kw):
    """
    Create objects into module
    """
    portal = self.getPortal()    
    module_id = sequence.get('module_id')
    module = portal._getOb(module_id, None)
    self.failUnless(module is not None)
    module_object_list = []
    for i in xrange(10):
      object = module.newContent(portal_type = 'Geek Object')
      self.failUnless(object is not None)
      module_object_list.append(object.getId())
    sequence.edit(module_object_id_list=module_object_list)    

  def stepRemoveModule(self, sequence=None, sequence_list=None, **kw):
    """
    Remove Module
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
    portal.manage_delObjects([module_id])
    self.failIf(portal._getOb(module_id, None) is not None)

  def stepCheckModuleExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of module
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
    new_module = portal._getOb(module_id, None)
    self.failIf(new_module is None)

  def stepCheckModuleObjectsExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of objects in module
    """
    portal = self.getPortal()
    module_id = sequence.get('module_id')
    module = portal._getOb(module_id)
    self.failUnless(module is not None)
    object_id_list = sequence.get('module_object_id_list')
    for object_id in object_id_list:
      object = module._getOb(object_id, None)
      self.failUnless(object is not None)

  def stepCheckModuleObjectsRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of objects in module
    """
    portal = self.getPortal()
    module_id = sequence.get('module_id')
    module = portal._getOb(module_id)
    self.failUnless(module is not None)
    object_id_list = sequence.get('module_object_id_list')
    for object_id in object_id_list:
      object = module._getOb(object_id, None)
      self.failUnless(object is None)
      
  def stepCheckModuleRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of module
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
    self.failIf(portal._getOb(module_id, None) is not None)    

  # skins folder
  def stepCreateSkinFolder(self, sequence=None, sequence_list=None, **kw):
    """
    Create a skin folder
    """
431
    ps = self.getSkinsTool()
Aurel's avatar
Aurel committed
432 433
    ps.manage_addProduct['OFSP'].manage_addFolder('erp5_geek')
    skin_folder = ps._getOb('erp5_geek', None)
434
    self.failUnless(skin_folder is not None)
Aurel's avatar
Aurel committed
435 436
    sequence.edit(skin_folder_id=skin_folder.getId())
    # add skin in layers
437 438
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
Aurel's avatar
Aurel committed
439 440
      if 'erp5_geek' not in selection:
        selection.append('erp5_geek')
441 442
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)

Aurel's avatar
Aurel committed
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
  def stepRemoveSkinFolder(self, sequence=None, sequence_list=None, **kw):
    """
    Remove Skin folder
    """
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    ps.manage_delObjects([skin_id])
    skin_folder = ps._getOb(skin_id, None)
    self.failUnless(skin_folder is None)
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
      if skin_id in selection:
        selection.remove(skin_id)
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)

  def stepCheckSkinFolderExists(self, sequence=None,sequence_list=None, **kw):
    """
    Check presence of skin folder
    """
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    self.failUnless(skin_folder is not None)    

  def stepCheckSkinFolderRemoved(self, sequence=None,sequence_list=None, **kw):
    """
    Check non presence of skin folder
    """
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    self.failUnless(skin_folder is None)

  def stepAddSkinFolderToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add sin folder to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    wf_ids = []
    wf_ids.append(sequence.get('skin_folder_id', ''))
    self.assertEqual(len(wf_ids), 1)
    bt.edit(template_skin_id_list=wf_ids)
486

Aurel's avatar
Aurel committed
487 488 489 490 491
  # Base Category
  def stepCreateBaseCategory(self, sequence=None, sequence_list=None, **kw):
    """
    Create Base category
    """
492
    pc = self.getCategoryTool()
Aurel's avatar
Aurel committed
493
    base_category = pc.newContent(portal_type = 'Base Category')
494
    self.failUnless(base_category is not None)
Aurel's avatar
Aurel committed
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
    sequence.edit(bc_id=base_category.getId())

  def stepAddBaseCategoryToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Base category to Business template
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    bt.edit(template_base_category_list=[bc_id])

  def stepAddBaseCategoryAsPathToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Base category to Business template
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'portal_categories/'+bc_id
    bt.edit(template_path_list=[path])

  def stepRemoveBaseCategory(self, sequence=None, sequence_list=None, **kw):
    """
    Remove Base category
    """
    pc = self.getCategoryTool()
    bc_id = sequence.get('bc_id')
    pc.manage_delObjects([bc_id])
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is None)    

  def stepCheckBaseCategoryExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of Base category
    """
    pc = self.getCategoryTool()
    bc_id = sequence.get('bc_id')
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)    

  def stepCheckBaseCategoryRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of Base category
    """
    pc = self.getCategoryTool()
    bc_id = sequence.get('bc_id')
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is None)    

  # categories
  def stepCreateCategories(self, sequence=None, sequence_list=None, **kw):
    """
    Create categories into a base category
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)    
    self.failUnless(base_category is not None)
    category_list = []
    for i in xrange(10):
      category = base_category.newContent(portal_type='Category')
      self.failUnless(category is not None)
      category_list.append(category.getId())
    sequence.edit(category_id_list=category_list)

  def stepAddCategoriesAsPathToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Categories in path with the joker *
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'portal_categories/'+bc_id+'/*'
    bt.edit(template_path_list=[path])

  def stepCheckCategoriesExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of categories
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)
    category_id_list = sequence.get('category_id_list')
    for category_id in category_id_list:
      category = base_category._getOb(category_id, None)
      self.failUnless(category is not None)

  def stepCheckCategoriesRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non-presence of categories
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)
    category_id_list = sequence.get('category_id_list')
    for category_id in category_id_list:
      category = base_category._getOb(category_id, None)
      self.failUnless(category is None)

  def stepRemoveCategories(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of categories
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)
    category_id_list = sequence.get('category_id_list')
    base_category.manage_delObjects(category_id_list)
    for category_id in category_id_list:
      category = base_category._getOb(category_id, None)
      self.failUnless(category is None)
      
  # sub categories
  def stepCreateSubCategories(self, sequence=None, sequence_list=None, **kw):
    """
    Add sub category to a category
    """
    pc = self.getCategoryTool()
    bc_id = sequence.get('bc_id')
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)
    cat_id_list = sequence.get('category_id_list')
    # only use one category
    cat_id = cat_id_list[0]
    category = base_category._getOb(cat_id, None)
620
    self.failUnless(category is not None)
Aurel's avatar
Aurel committed
621 622 623 624 625 626
    subcategory_list = []
    for i in xrange(10):
      subcategory = category.newContent(portal_type='Category')
      self.failUnless(subcategory is not None)
      subcategory_list.append(subcategory.getId())
    sequence.edit(subcategory_id_list=subcategory_list, parent_category_id=category.getId())
627

Aurel's avatar
Aurel committed
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
  def stepAddSubCategoriesAsPathToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add All Categories in path with the joker **
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'portal_categories/'+bc_id+'/**'
    bt.edit(template_path_list=[path])
  
  def stepCheckSubCategoriesExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of categories
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    self.failUnless(base_category is not None)
    parent_category_id = sequence.get('parent_category_id')
    category = base_category._getOb(parent_category_id, None)
    self.failUnless(category is not None)
    subcategory_id_list = sequence.get('subcategory_id_list')
    for subcategory_id in subcategory_id_list:
      subcategory = category._getOb(subcategory_id, None)
      self.failUnless(subcategory is not None)
  
  # workflow
  def stepCreateWorkflow(self, sequence=None, sequence_list=None, **kw):
    """
    Create a workflow
    """
658 659
    pw = self.getWorkflowTool()
    pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', 'geek_workflow')
Aurel's avatar
Aurel committed
660 661 662
    workflow = pw._getOb('geek_workflow', None)
    self.failUnless(workflow is not None)
    sequence.edit(workflow_id=workflow.getId())
663 664 665 666 667 668 669 670
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
        props['chain_%s' % id] = ','.join(wf_ids)
    props['chain_geek'] = 'geek_workflow'
    pw.manage_changeWorkflows('', props=props)

Aurel's avatar
Aurel committed
671
  def stepAddWorkflowToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
672
    """
Aurel's avatar
Aurel committed
673
    Add workflow to business template
674
    """
Aurel's avatar
Aurel committed
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    wf_ids = []
    wf_ids.append(sequence.get('workflow_id', ''))
    self.assertEqual(len(wf_ids), 1)
    bt.edit(template_workflow_id_list=wf_ids)
    
  def stepRemoveWorkflow(self, sequence=None, sequence_list=None, **kw):
    """
    Remove Workflow
    """
    wf_id = sequence.get('workflow_id')
    pw = self.getWorkflowTool()
    pw.manage_delObjects([wf_id])
    workflow = pw._getOb(wf_id, None)
    self.failUnless(workflow is None)
691

Aurel's avatar
Aurel committed
692 693 694 695 696 697 698 699
  def stepCheckWorkflowExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of Workflow
    """
    wf_id = sequence.get('workflow_id')
    pw = self.getWorkflowTool()
    workflow = pw._getOb(wf_id, None)
    self.failUnless(workflow is not None)
700

Aurel's avatar
Aurel committed
701 702 703 704 705 706 707 708
  def stepCheckWorkflowRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of Workflow
    """
    wf_id = sequence.get('workflow_id')
    pw = self.getWorkflowTool()
    workflow = pw._getOb(wf_id, None)
    self.failUnless(workflow is None)
709

Aurel's avatar
Aurel committed
710
  # Actions
Aurel's avatar
Aurel committed
711
  def stepCreateAction(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
712
    """
Aurel's avatar
Aurel committed
713
    Create action
Aurel's avatar
Aurel committed
714 715 716 717 718 719 720 721 722 723 724 725
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    object_pt.addAction(
      id = 'become_geek'
      , name = 'Become Geek'
      , action = 'become_geek_action'
      , condition = ''
      , permission = ('View', )
      , category = 'object_action'
      , visible = 1
Aurel's avatar
Aurel committed
726 727 728 729 730 731 732 733 734 735 736
      , optional = 0
      , priority = 2.0 )
    sequence.edit(action_id='become_geek')

  def stepCreateOptionalAction(self, sequence=None, sequence_list=None, **kw):
    """
    Create optional action
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
737 738 739 740 741 742 743 744
    object_pt.addAction(
      id = 'become_nerd'
      , name = 'Become Nerd'
      , action = 'become_nerd_action'
      , condition = ''
      , permission = ('View', )
      , category = 'object_action'
      , visible = 1
Aurel's avatar
Aurel committed
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
      , optional = 1
      , priority = 1.5 )
    sequence.edit(opt_action_id='become_nerd')

  def stepCheckActionsOrder(self, sequence=None, sequence_list=None, **kw):
    """
    Check Actions Order
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    actions_list = object_pt.listActions()
    priority = 0
    for action in actions_list:
      self.failIf(action.priority < priority)
      priority = action.priority

762

Aurel's avatar
Aurel committed
763 764 765 766 767 768 769 770 771
  def stepCheckActionExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of action 
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    action_id = sequence.get('action_id')
    self.failUnless(action_id in [x.getId() for x in object_pt.listActions()])
772

Aurel's avatar
Aurel committed
773 774 775 776 777 778 779 780 781
  def stepCheckActionNotExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check non-presence of action 
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    action_id = sequence.get('action_id')
    self.failUnless(action_id not in [x.getId() for x in object_pt.listActions()])
782

Aurel's avatar
Aurel committed
783 784 785 786 787 788 789 790 791
  def stepCheckOptionalActionExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of optional action 
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    action_id = sequence.get('opt_action_id')
    self.failUnless(action_id in [x.getId() for x in object_pt.listActions()])
792

Aurel's avatar
Aurel committed
793 794 795 796 797 798 799 800 801
  def stepCheckOptionalActionNotExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check non-presence of optional action 
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    action_id = sequence.get('opt_action_id')
    self.failUnless(action_id not in [x.getId() for x in object_pt.listActions()])    
802

Aurel's avatar
Aurel committed
803 804 805 806 807 808 809 810 811 812 813 814
  def stepAddOptionalActionToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add optionpal action into the business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    opt_action_id = sequence.get('opt_action_id', None)
    self.failUnless(opt_action_id is not None)
    object_ptype_id = sequence.get('object_ptype_id', None)
    self.failUnless(object_ptype_id is not None)
    action_path = object_ptype_id+'[id='+opt_action_id+']'
    bt.edit(template_action_path_list=[action_path])
815

Aurel's avatar
Aurel committed
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
  # Catalog Method
  def stepCreateCatalogMethod(self, sequence=None, sequence_list=None, **kw):
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
    catalog = pc._getOb('erp5_mysql', None)
    self.failUnless(catalog is not None)
    method_id = "z_fake_method"
    addSQLMethod =catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
    addSQLMethod(id=method_id,title='', connection_id='test test', arguments='', template='')
    zsql_method = catalog._getOb(method_id, None)  
    self.failUnless(zsql_method is not None)
    sequence.edit(zsql_method_id = method_id)
    # set this method in update_object properties of catalog
    sql_uncatalog_object = list(catalog.sql_uncatalog_object)
    sql_uncatalog_object.append(method_id)
    sql_uncatalog_object.sort()
    catalog.sql_uncatalog_object = tuple(sql_uncatalog_object)
    # set filter for this method
    expression = 'python: isMovement'
    expr_instance = Expression(expression)
    catalog.filter_dict[method_id] = PersistentMapping()
    catalog.filter_dict[method_id]['filtered'] = 1
    catalog.filter_dict[method_id]['expression'] = expression
    catalog.filter_dict[method_id]['expression_instance'] = expr_instance
    catalog.filter_dict[method_id]['type'] = []
843
    
Aurel's avatar
Aurel committed
844 845 846 847 848 849 850 851 852
  def stepAddCatalogMethodToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add catalog method into the business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    method_id = sequence.get('zsql_method_id', None)
    self.failUnless(method_id is not None)
    bt.edit(template_catalog_method_id_list=['erp5_mysql/'+method_id])
853

Aurel's avatar
Aurel committed
854 855 856 857 858 859 860 861
  def stepCheckCatalogMethodExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of ZSQL Method in catalog
    """
    pc = self.getCatalogTool()
    catalog = pc._getOb('erp5_mysql', None)
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
862
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
863 864 865 866 867 868 869 870 871
    self.failUnless(zsql_method is not None)
    # check catalog properties
    self.failUnless(method_id in catalog.sql_uncatalog_object)
    # check filter
    self.failUnless(method_id in catalog.filter_dict.keys())
    filter_dict = catalog.filter_dict[method_id]
    self.assertEqual(filter_dict['filtered'], 1)
    self.assertEqual(filter_dict['expression'], 'python: isMovement')
    self.assertEqual(filter_dict['type'], [])
872

Aurel's avatar
Aurel committed
873
  def stepCheckCatalogMethodRemoved(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
874
    """
Aurel's avatar
Aurel committed
875
    Check non-presence of ZSQL Method in catalog
Romain Courteaud's avatar
Romain Courteaud committed
876
    """
Aurel's avatar
Aurel committed
877 878 879 880 881 882 883 884 885 886
    pc = self.getCatalogTool()
    catalog = pc._getOb('erp5_mysql', None)
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
    zsql_method = catalog._getOb(method_id, None)  
    self.failUnless(zsql_method is None)
    # check catalog properties
    self.failUnless(method_id not in catalog.sql_uncatalog_object)
    # check filter
    self.failUnless(method_id not in catalog.filter_dict.keys())
Romain Courteaud's avatar
Romain Courteaud committed
887

Aurel's avatar
Aurel committed
888 889
    
  def stepRemoveCatalogMethod(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
890
    """
Aurel's avatar
Aurel committed
891
    Remove ZSQL Method from catalog
Romain Courteaud's avatar
Romain Courteaud committed
892
    """
Aurel's avatar
Aurel committed
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
    pc = self.getCatalogTool()
    catalog = pc._getOb('erp5_mysql', None)
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
    catalog.manage_delObjects([method_id])
    zsql_method = catalog._getOb(method_id, None)
    self.failUnless(zsql_method is None)
    # remove catalog properties
    sql_uncatalog_object = list(catalog.sql_uncatalog_object)
    sql_uncatalog_object.remove(method_id)
    sql_uncatalog_object.sort()
    catalog.sql_uncatalog_object = tuple(sql_uncatalog_object)
    self.failUnless(method_id not in catalog.sql_uncatalog_object)
    # remove filter
    del catalog.filter_dict[method_id]
    self.failUnless(method_id not in catalog.filter_dict.keys())        
Romain Courteaud's avatar
Romain Courteaud committed
909

Aurel's avatar
Aurel committed
910
  # Related key, Result key and table, and others
Aurel's avatar
Aurel committed
911
  def stepCreateKeysAndTable(self, sequence=list, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
912
    """
Aurel's avatar
Aurel committed
913
    Create some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
914
    """
Aurel's avatar
Aurel committed
915 916 917
    related_key = 'fake_id | category/catalog/z_fake_method'
    result_key = 'fake_catalog.uid'
    result_table = 'fake_catalog'
Aurel's avatar
Aurel committed
918 919 920 921 922
    keyword_key = 'fake_keyword'
    full_text_key = 'fake_full_text'
    request_key = 'fake_request'
    multivalue_key = 'fake_multivalue'
    topic_key = 'fake_topic'
Aurel's avatar
Aurel committed
923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
    catalog = self.getCatalogTool().getSQLCatalog()
    self.failUnless(catalog is not None)
    # result key
    sql_search_result_keys = list(catalog.sql_search_result_keys)
    sql_search_result_keys.append(result_key)
    sql_search_result_keys.sort()
    catalog.sql_search_result_keys = tuple(sql_search_result_keys)
    self.failUnless(result_key in catalog.sql_search_result_keys)
    # related key
    sql_search_related_keys = list(catalog.sql_catalog_related_keys)
    sql_search_related_keys.append(related_key)
    sql_search_related_keys.sort()
    catalog.sql_catalog_related_keys = tuple(sql_search_related_keys)
    self.failUnless(related_key in catalog.sql_catalog_related_keys)
    # result table
    sql_search_tables = list(catalog.sql_search_tables)
    sql_search_tables.append(result_table)
    sql_search_tables.sort()
    catalog.sql_search_tables = tuple(sql_search_tables)
    self.failUnless(result_table in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976
    # keyword keys
    sql_catalog_keyword_keys = list(catalog.sql_catalog_keyword_search_keys)
    sql_catalog_keyword_keys.append(keyword_key)
    sql_catalog_keyword_keys.sort()
    catalog.sql_catalog_keyword_search_keys = tuple(sql_catalog_keyword_keys)
    self.failUnless(keyword_key in catalog.sql_catalog_keyword_search_keys)
    # full_text keys
    sql_catalog_full_text_keys = list(catalog.sql_catalog_full_text_search_keys)
    sql_catalog_full_text_keys.append(full_text_key)
    sql_catalog_full_text_keys.sort()
    catalog.sql_catalog_full_text_search_keys = tuple(sql_catalog_full_text_keys)
    self.failUnless(full_text_key in catalog.sql_catalog_full_text_search_keys)
    # request
    sql_catalog_request_keys = list(catalog.sql_catalog_request_keys)
    sql_catalog_request_keys.append(request_key)
    sql_catalog_request_keys.sort()
    catalog.sql_catalog_request_keys = tuple(sql_catalog_request_keys)
    self.failUnless(request_key in catalog.sql_catalog_request_keys)
    # multivalue
    sql_catalog_multivalue_keys = list(catalog.sql_catalog_multivalue_keys)
    sql_catalog_multivalue_keys.append(multivalue_key)
    sql_catalog_multivalue_keys.sort()
    catalog.sql_catalog_multivalue_keys = tuple(sql_catalog_multivalue_keys)
    self.failUnless(multivalue_key in catalog.sql_catalog_multivalue_keys)
    # topic keys
    sql_catalog_topic_keys = list(catalog.sql_catalog_topic_search_keys)
    sql_catalog_topic_keys.append(topic_key)
    sql_catalog_topic_keys.sort()
    catalog.sql_catalog_topic_search_keys = tuple(sql_catalog_topic_keys)
    self.failUnless(topic_key in catalog.sql_catalog_topic_search_keys)

    sequence.edit(related_key=related_key, result_key=result_key, result_table=result_table, \
                  keyword_key=keyword_key, full_text_key=full_text_key, request_key=request_key, \
                  multivalue_key=multivalue_key, topic_key=topic_key)
Aurel's avatar
Aurel committed
977 978 979 980 981 982 983 984 985 986 987 988 989
    
  def stepAddKeysAndTableToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add some related, result key and tables to Business Temlpate
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    related_key = sequence.get('related_key', None)
    self.failUnless(related_key is not None)
    result_key = sequence.get('result_key', None)
    self.failUnless(result_key is not None)
    result_table = sequence.get('result_table', None)
    self.failUnless(result_table is not None)
Aurel's avatar
Aurel committed
990 991 992 993 994 995 996 997 998 999 1000
    keyword_key = sequence.get('keyword_key', None)
    self.failUnless(keyword_key is not None)
    full_text_key = sequence.get('full_text_key', None)
    self.failUnless(full_text_key is not None)
    request_key = sequence.get('request_key', None)
    self.failUnless(request_key is not None)
    multivalue_key = sequence.get('multivalue_key', None)
    self.failUnless(multivalue_key is not None)
    topic_key = sequence.get('topic_key', None)
    self.failUnless(topic_key is not None)
    
Aurel's avatar
Aurel committed
1001 1002
    bt.edit(template_catalog_related_key_list=[related_key],
            template_catalog_result_key_list=[result_key],
Aurel's avatar
Aurel committed
1003 1004 1005 1006 1007 1008
            template_catalog_result_table_list=[result_table],
            template_catalog_keyword_key_list=[keyword_key],
            template_catalog_full_text_key_list=[full_text_key],
            template_catalog_request_key_list=[request_key],
            template_catalog_multivalue_key_list=[multivalue_key],
            template_catalog_topic_key_list=[topic_key],
Aurel's avatar
Aurel committed
1009
            )
Romain Courteaud's avatar
Romain Courteaud committed
1010

Aurel's avatar
Aurel committed
1011
  def stepRemoveKeysAndTable(self, sequence=list, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1012
    """
Aurel's avatar
Aurel committed
1013
    Remove some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
1014
    """
Aurel's avatar
Aurel committed
1015 1016 1017 1018 1019 1020
    related_key = sequence.get('related_key', None)
    self.failUnless(related_key is not None)
    result_key = sequence.get('result_key', None)
    self.failUnless(result_key is not None)
    result_table = sequence.get('result_table', None)
    self.failUnless(result_table is not None)
Aurel's avatar
Aurel committed
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
    keyword_key = sequence.get('keyword_key', None)
    self.failUnless(keyword_key is not None)
    full_text_key = sequence.get('full_text_key', None)
    self.failUnless(full_text_key is not None)
    request_key = sequence.get('request_key', None)
    self.failUnless(request_key is not None)
    multivalue_key = sequence.get('multivalue_key', None)
    self.failUnless(multivalue_key is not None)
    topic_key = sequence.get('topic_key', None)
    self.failUnless(topic_key is not None)

Aurel's avatar
Aurel committed
1032
    catalog = self.getCatalogTool().getSQLCatalog()
Aurel's avatar
Aurel committed
1033
    self.failUnless(catalog is not None)    
Aurel's avatar
Aurel committed
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
    # result key
    sql_search_result_keys = list(catalog.sql_search_result_keys)
    sql_search_result_keys.remove(result_key)
    sql_search_result_keys.sort()
    catalog.sql_search_result_keys = tuple(sql_search_result_keys)
    self.failUnless(result_key not in catalog.sql_search_result_keys)
    # related key
    sql_search_related_keys = list(catalog.sql_catalog_related_keys)
    sql_search_related_keys.remove(related_key)
    sql_search_related_keys.sort()
    catalog.sql_catalog_related_keys = tuple(sql_search_related_keys)
    self.failUnless(related_key not in catalog.sql_catalog_related_keys)
    # result table
    sql_search_tables = list(catalog.sql_search_tables)
    sql_search_tables.remove(result_table)
    sql_search_tables.sort()
    catalog.sql_search_tables = tuple(sql_search_tables)
    self.failUnless(result_table not in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082
    # keyword keys
    sql_catalog_keyword_keys = list(catalog.sql_catalog_keyword_search_keys)
    sql_catalog_keyword_keys.remove(keyword_key)
    sql_catalog_keyword_keys.sort()
    catalog.sql_catalog_keyword_search_keys = tuple(sql_catalog_keyword_keys)
    self.failUnless(keyword_key not in catalog.sql_catalog_keyword_search_keys)
    # full_text keys
    sql_catalog_full_text_keys = list(catalog.sql_catalog_full_text_search_keys)
    sql_catalog_full_text_keys.remove(full_text_key)
    sql_catalog_full_text_keys.sort()
    catalog.sql_catalog_full_text_search_keys = tuple(sql_catalog_full_text_keys)
    self.failUnless(full_text_key not in catalog.sql_catalog_full_text_search_keys)
    # request
    sql_catalog_request_keys = list(catalog.sql_catalog_request_keys)
    sql_catalog_request_keys.remove(request_key)
    sql_catalog_request_keys.sort()
    catalog.sql_catalog_request_keys = tuple(sql_catalog_request_keys)
    self.failUnless(request_key not in catalog.sql_catalog_request_keys)
    # multivalue
    sql_catalog_multivalue_keys = list(catalog.sql_catalog_multivalue_keys)
    sql_catalog_multivalue_keys.remove(multivalue_key)
    sql_catalog_multivalue_keys.sort()
    catalog.sql_catalog_multivalue_keys = tuple(sql_catalog_multivalue_keys)
    self.failUnless(multivalue_key not in catalog.sql_catalog_multivalue_keys)
    # topic keys
    sql_catalog_topic_keys = list(catalog.sql_catalog_topic_search_keys)
    sql_catalog_topic_keys.remove(topic_key)
    sql_catalog_topic_keys.sort()
    catalog.sql_catalog_topic_search_keys = tuple(sql_catalog_topic_keys)
    self.failUnless(topic_key not in catalog.sql_catalog_topic_search_keys)

Romain Courteaud's avatar
Romain Courteaud committed
1083

Aurel's avatar
Aurel committed
1084
  def stepCheckKeysAndTableExists(self, sequence=list, sequence_list=None, **kw):
1085
    """
Aurel's avatar
Aurel committed
1086
    Check presence of some keys and tables
1087
    """
Aurel's avatar
Aurel committed
1088 1089 1090 1091 1092 1093
    related_key = sequence.get('related_key', None)
    self.failUnless(related_key is not None)
    result_key = sequence.get('result_key', None)
    self.failUnless(result_key is not None)
    result_table = sequence.get('result_table', None)
    self.failUnless(result_table is not None)
Aurel's avatar
Aurel committed
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
    keyword_key = sequence.get('keyword_key', None)
    self.failUnless(keyword_key is not None)
    full_text_key = sequence.get('full_text_key', None)
    self.failUnless(full_text_key is not None)
    request_key = sequence.get('request_key', None)
    self.failUnless(request_key is not None)
    multivalue_key = sequence.get('multivalue_key', None)
    self.failUnless(multivalue_key is not None)
    topic_key = sequence.get('topic_key', None)
    self.failUnless(topic_key is not None)

Aurel's avatar
Aurel committed
1105 1106 1107 1108 1109 1110 1111 1112
    catalog = self.getCatalogTool().getSQLCatalog()
    self.failUnless(catalog is not None)
    # result key
    self.failUnless(result_key in catalog.sql_search_result_keys)
    # related key
    self.failUnless(related_key in catalog.sql_catalog_related_keys)
    # result table
    self.failUnless(result_table in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
    # keyword key
    self.failUnless(keyword_key in catalog.sql_catalog_keyword_search_keys)
    # full text key
    self.failUnless(full_text_key in catalog.sql_catalog_full_text_search_keys)
    # request key
    self.failUnless(request_key in catalog.sql_catalog_request_keys)
    # multivalue key
    self.failUnless(multivalue_key in catalog.sql_catalog_multivalue_keys)
    # topic key
    self.failUnless(topic_key in catalog.sql_catalog_topic_search_keys)
1123

Aurel's avatar
Aurel committed
1124
  def stepCheckKeysAndTableRemoved(self, sequence=list, sequence_list=None, **kw):
1125
    """
Aurel's avatar
Aurel committed
1126
    Check non-presence of some keys and tables
1127
    """
Aurel's avatar
Aurel committed
1128 1129 1130 1131 1132 1133
    related_key = sequence.get('related_key', None)
    self.failUnless(related_key is not None)
    result_key = sequence.get('result_key', None)
    self.failUnless(result_key is not None)
    result_table = sequence.get('result_table', None)
    self.failUnless(result_table is not None)
Aurel's avatar
Aurel committed
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
    keyword_key = sequence.get('keyword_key', None)
    self.failUnless(keyword_key is not None)
    full_text_key = sequence.get('full_text_key', None)
    self.failUnless(full_text_key is not None)
    request_key = sequence.get('request_key', None)
    self.failUnless(request_key is not None)
    multivalue_key = sequence.get('multivalue_key', None)
    self.failUnless(multivalue_key is not None)
    topic_key = sequence.get('topic_key', None)
    self.failUnless(topic_key is not None)

Aurel's avatar
Aurel committed
1145 1146 1147 1148 1149 1150 1151 1152
    catalog = self.getCatalogTool().getSQLCatalog()
    self.failUnless(catalog is not None)
    # result key
    self.failUnless(result_key not in catalog.sql_search_result_keys)
    # related key
    self.failUnless(related_key not in catalog.sql_catalog_related_keys)
    # result table
    self.failUnless(result_table not in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162
    # keyword key
    self.failUnless(keyword_key not in catalog.sql_catalog_keyword_search_keys)
    # full text key
    self.failUnless(full_text_key not in catalog.sql_catalog_full_text_search_keys)
    # request key
    self.failUnless(request_key not in catalog.sql_catalog_request_keys)
    # multivalue key
    self.failUnless(multivalue_key not in catalog.sql_catalog_multivalue_keys)
    # topic key
    self.failUnless(topic_key not in catalog.sql_catalog_topic_search_keys)
1163

Aurel's avatar
Aurel committed
1164 1165
  # Roles
  def stepCreateRole(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1166
    """
Aurel's avatar
Aurel committed
1167
    Create a role
Romain Courteaud's avatar
Romain Courteaud committed
1168
    """
Aurel's avatar
Aurel committed
1169 1170 1171 1172 1173 1174 1175
    new_role = "Unit Tester"
    p = self.getPortal()
    role_list = list(p.__ac_roles__)
    role_list.append(new_role)
    p.__ac_roles__ = tuple(role_list)
    self.failUnless(new_role in p.__ac_roles__)
    sequence.edit(role=new_role)
Romain Courteaud's avatar
Romain Courteaud committed
1176

Aurel's avatar
Aurel committed
1177
  def stepRemoveRole(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1178
    """
Aurel's avatar
Aurel committed
1179
    Remove a role
Romain Courteaud's avatar
Romain Courteaud committed
1180
    """
Aurel's avatar
Aurel committed
1181 1182 1183 1184 1185 1186 1187
    role = sequence.get('role', None)
    self.failUnless(role is not None)
    p = self.getPortal()
    role_list = list(p.__ac_roles__)
    role_list.remove(role)
    p.__ac_roles__ = tuple(role_list)
    self.failUnless(role not in p.__ac_roles__)
Romain Courteaud's avatar
Romain Courteaud committed
1188

Aurel's avatar
Aurel committed
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208
  def stepAddRoleToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Role to Business Template
    """
    role = sequence.get('role', None)
    self.failUnless(role is not None)
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_role_list=[role])

  def stepCheckRoleExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of role
    """
    role = sequence.get('role', None)
    self.failUnless(role is not None)
    p = self.getPortal()
    self.failUnless(role in p.__ac_roles__)
    
  def stepCheckRoleRemoved(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1209
    """
Aurel's avatar
Aurel committed
1210
    Check non-presence of role
Romain Courteaud's avatar
Romain Courteaud committed
1211
    """
Aurel's avatar
Aurel committed
1212 1213 1214 1215
    role = sequence.get('role', None)
    self.failUnless(role is not None)
    p = self.getPortal()
    self.failUnless(role not in p.__ac_roles__)
Romain Courteaud's avatar
Romain Courteaud committed
1216

Aurel's avatar
Aurel committed
1217 1218 1219
  # Document, Property Sheet, Extension And Test
  # they use the same class so only one test is required for them
  def stepCreatePropertySheet(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1220
    """
Aurel's avatar
Aurel committed
1221
    Create a Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
1222
    """
Aurel's avatar
Aurel committed
1223 1224 1225
    ps_title = 'UnitTest'
    ps_data =  ' \nclass UnitTest: \n  """ \n  Fake property sheet for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
Romain Courteaud's avatar
Romain Courteaud committed
1226
    cfg = getConfiguration()
Aurel's avatar
Aurel committed
1227 1228 1229 1230 1231 1232 1233 1234
    file_path = os.path.join(cfg.instancehome, 'PropertySheet', ps_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(ps_data)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(ps_title=ps_title, ps_path=file_path)
Romain Courteaud's avatar
Romain Courteaud committed
1235

Aurel's avatar
Aurel committed
1236
  def stepAddPropertySheetToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1237
    """
Aurel's avatar
Aurel committed
1238
    Add Property Sheet to Business Template
Romain Courteaud's avatar
Romain Courteaud committed
1239
    """
Aurel's avatar
Aurel committed
1240 1241 1242 1243 1244
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    ps_title = sequence.get('ps_title', None)
    self.failUnless(ps_title is not None)
    bt.edit(template_property_sheet_id_list=[ps_title])
Romain Courteaud's avatar
Romain Courteaud committed
1245

Aurel's avatar
Aurel committed
1246
  def stepRemovePropertySheet(self, sequence=None, sequencer_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1247
    """
Aurel's avatar
Aurel committed
1248
    Remove Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
1249
    """
Aurel's avatar
Aurel committed
1250 1251 1252 1253 1254
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
    self.failUnless(os.path.exists(ps_path))
    os.remove(ps_path)
    self.failIf(os.path.exists(ps_path))
1255

Aurel's avatar
Aurel committed
1256 1257 1258 1259 1260 1261 1262
  def stepCheckPropertySheetExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Property Sheet
    """
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
    self.failUnless(os.path.exists(ps_path))
1263

Aurel's avatar
Aurel committed
1264
  def stepCheckPropertySheetRemoved(self, sequence=None, sequencer_list=None, **kw):
1265
    """
Aurel's avatar
Aurel committed
1266 1267 1268 1269 1270 1271 1272 1273
    Check presence of Property Sheet
    """
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
    self.failIf(os.path.exists(ps_path))
    
  # Busines templates
  def stepImportBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1274
    """
Aurel's avatar
Aurel committed
1275 1276 1277
    Import Business Template from a dir
    """
    template_path = sequence.get('template_path')
1278
    template_tool = self.getTemplateTool()
Aurel's avatar
Aurel committed
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
    exported_bt_id = sequence.get('export_bt').getId()
    import_id = 'imported_%s' %exported_bt_id
    n = 0
    while import_id in template_tool.objectIds():
      n = n + 1    
      import_id = "%s_%s" %(import_id, n)
    template_tool.download(url='file:'+template_path, id=import_id)
    import_bt = template_tool._getOb(id=import_id)
    self.failIf(import_bt is None)
    self.assertEquals(import_bt.getPortalType(), 'Business Template')
    sequence.edit(import_bt=import_bt)
    
  def stepInstallBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Install importzed business template
    """
    import_bt = sequence.get('import_bt')
    import_bt.install(force=1)
1297

Aurel's avatar
Aurel committed
1298
  def stepCreateNewBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1299
    """
Aurel's avatar
Aurel committed
1300
    Create a new Business Template
1301
    """
Aurel's avatar
Aurel committed
1302 1303 1304 1305 1306 1307 1308 1309
    pt = self.getTemplateTool()
    template = pt.newContent(portal_type='Business Template')
    self.failUnless(template.getBuildingState() == 'draft')
    self.failUnless(template.getInstallationState() == 'not_installed')
    template.edit(title='geek template',
                  version='1.0',
                  description='bt for unit_test')
    sequence.edit(export_bt=template)
1310

Aurel's avatar
Aurel committed
1311
  def stepBuildBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1312
    """
Aurel's avatar
Aurel committed
1313
    Build Business Template
1314
    """
Aurel's avatar
Aurel committed
1315 1316
    template = sequence.get('current_bt')  
    template.build()
Romain Courteaud's avatar
Romain Courteaud committed
1317

Aurel's avatar
Aurel committed
1318
  def stepSaveBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Yoshinori Okuji's avatar
Yoshinori Okuji committed
1319
    """
Aurel's avatar
Aurel committed
1320
    Export Business Template
Yoshinori Okuji's avatar
Yoshinori Okuji committed
1321
    """
Aurel's avatar
Aurel committed
1322 1323 1324 1325 1326 1327 1328
    template = sequence.get('current_bt')
    cfg = getConfiguration()
    bt_title = pathname2url(template.getTitle())
    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (bt_title,))
    template.export(path=template_path, local=1)
    sequence.edit(template_path=template_path)
    self.failUnless(os.path.exists(template_path))
Yoshinori Okuji's avatar
Yoshinori Okuji committed
1329

Aurel's avatar
Aurel committed
1330
  def stepCheckObjectPropertiesInBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1331
    """
Aurel's avatar
Aurel committed
1332
    Check that ac_local_roles, uid and _owner are set to None
1333
    """
Aurel's avatar
Aurel committed
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
    bt = sequence.get('current_bt')
    item_list = [
      '_workflow_item',
      '_catalog_method_item',
      '_portal_type_item',
      '_category_item',
      '_skin_item',
      '_path_item',
      '_action_item',
    ]
    for item_name in item_list:
      item = getattr(bt, item_name)
      if item is not None:
        for key, data in item._objects.items():
          if hasattr(data, '__ac_local_roles__'):
            self.failUnless(data.__ac_local_roles__ is None)
          if hasattr(data, '_owner'):
            self.failUnless(data._owner is None)
          if hasattr(aq_base(data), 'uid'):
            self.failUnless(data.uid is None)
1354

Aurel's avatar
Aurel committed
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374
  def stepSetUpdateWorkflowFlagInBusinessTemplate(self, sequence=None, sequence_list=None):
    """
    Set flag for update in Business Template    
    """
    template_tool = self.getTemplateTool()
    bt = sequence.get('current_bt')
    self.assertEqual(bt.getTitle(),'erp5_core')
    bt.edit(template_update_business_template_workflow=1)
    self.assertEqual(bt.getTemplateUpdateBusinessTemplateWorkflow(), 1)

  def stepSetUpdateToolFlagInBusinessTemplate(self, sequence=None, sequence_list=None):
    """
    Set flag for update in Business Template    
    """
    template_tool = self.getTemplateTool()
    bt = sequence.get('current_bt')
    self.assertEqual(bt.getTitle(),'erp5_core')
    bt.edit(template_update_tool=1)
    self.assertEqual(bt.getTemplateUpdateTool(), 1)

Aurel's avatar
Aurel committed
1375
  def stepRemoveBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1376
    """
Aurel's avatar
Aurel committed
1377
    Remove current Business Template
1378
    """
Aurel's avatar
Aurel committed
1379 1380 1381 1382 1383 1384 1385
    bt_id = sequence.get('current_bt').getId()
    template_tool = self.getTemplateTool()
    template_tool.manage_delObjects([bt_id])
    bt = template_tool._getOb(bt_id, None)
    self.failUnless(bt is None)

  def stepUninstallBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1386
    """
Aurel's avatar
Aurel committed
1387
    Uninstall current Business Template
Romain Courteaud's avatar
Romain Courteaud committed
1388
    """
Aurel's avatar
Aurel committed
1389 1390 1391
    bt = sequence.get('current_bt')
    bt.uninstall()

1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
  def stepClearBusinessTemplateField(self, sequence=None, sequence_list=None, **kw):
    """
    Clear business template field
    """
    bt = sequence.get('current_bt')
    prop_dict = {}
    for prop in bt.propertyMap():
      prop_type = prop['type']
      pid = prop['id']
      if pid in ('id', 'uid', 'rid', 'sid', 'id_group', 'last_id',
                'install_object_list_list', 'title', 'version', 'description'):
          continue
      if prop_type == 'text' or prop_type == 'string':
        prop_dict[pid] = ''
      elif prop_type == 'int':
        prop_dict[pid] = 0
      elif prop_type == 'lines' or prop_type == 'tokens':
        prop_dict[pid[:-5]] = ()
    bt.edit(**prop_dict)

1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
  def stepRemoveTrashTool(self, sequence=None, sequence_list=None, **kw):
    """
    Remove Trash Tool from site
    """
    p = self.getPortal()
    p.manage_delObjects(['portal_trash'])
    self.failUnless(p._getOb('portal_trash', None) is None)

  def stepCheckTrashToolExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of trash tool
    """
    self.failUnless(self.getTrashTool() is not None)
1425
          
Aurel's avatar
Aurel committed
1426 1427
  # tests
  def test_01_checkNewSite(self, quiet=0, run=run_all_test):
Romain Courteaud's avatar
Romain Courteaud committed
1428 1429
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1430
      message = 'Test Check New Site'
Romain Courteaud's avatar
Romain Courteaud committed
1431 1432 1433 1434
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
1435 1436 1437 1438 1439 1440 1441
                       UseCoreBusinessTemplate  \
                       CheckTools \
                       CheckBuiltBuildingState \
                       CheckInstalledInstallationState \
                       CheckSkinsLayers \
                       CheckNoTrashBin \
                       '
1442
    sequence_list.addSequenceString(sequence_string)
Aurel's avatar
Aurel committed
1443
    sequence_list.play(self)      
1444

Aurel's avatar
Aurel committed
1445 1446
  # test of portal types
  def test_02_BusinessTemplateWithPortalTypes(self, quiet=0, run=run_all_test):
1447 1448
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1449
      message = 'Test Business Template With Portal Types'
1450 1451 1452 1453
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485
                       CreatePortalType \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
1486
    sequence_list.addSequenceString(sequence_string)
Aurel's avatar
Aurel committed
1487
    sequence_list.play(self)    
1488

Aurel's avatar
Aurel committed
1489 1490
  # test of skins
  def test_03_BusinessTemplateWithSkins(self, quiet=0, run=run_all_test):
1491 1492
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1493
      message = 'Test Business Template With Skin Folder'
1494 1495 1496 1497
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529
                       CreateSkinFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveSkinFolder \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckSkinFolderExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSkinFolderRemoved \
                       '
1530
    sequence_list.addSequenceString(sequence_string)
Aurel's avatar
Aurel committed
1531
    sequence_list.play(self)    
1532

Aurel's avatar
Aurel committed
1533 1534
  # test of workflow
  def test_04_BusinessTemplateWithWorkflow(self, quiet=0, run=run_all_test):
1535 1536
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1537
      message = 'Test Business Template With Workflow'
1538 1539 1540 1541
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667
                       CreateWorkflow \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckWorkflowExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckWorkflowRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

  # test of module
  def test_05_BusinessTemplateWithModule(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Module'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveModule \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckModuleObjectsRemoved \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckModuleRemoved \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

  # test of categories
  def test_06_BusinessTemplateWithBaseCategory(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Base Category'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
1668 1669
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
Aurel's avatar
Aurel committed
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680
    
  # test of actions
  def test_07_BusinessTemplateWithoutOptionalAction(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template Without Optional Action'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
1681 1682
                       CreateAction \
                       CreateOptionalAction \
Aurel's avatar
Aurel committed
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddPortalTypeToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckActionExists \
                       CheckOptionalActionNotExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    
1718

Aurel's avatar
Aurel committed
1719 1720 1721 1722 1723 1724 1725 1726 1727
  def test_08_BusinessTemplateWithOptionalAction(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Optional Action'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
1728 1729
                       CreateAction \
                       CreateOptionalAction \
Aurel's avatar
Aurel committed
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddOptionalActionToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       CreatePortalType \
Aurel's avatar
Aurel committed
1746
                       CreateAction \
Aurel's avatar
Aurel committed
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
Aurel's avatar
Aurel committed
1757
                       CheckActionExists \
Aurel's avatar
Aurel committed
1758
                       CheckOptionalActionExists \
Aurel's avatar
Aurel committed
1759
                       CheckActionsOrder \
Aurel's avatar
Aurel committed
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckOptionalActionNotExists \
                       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

  def test_09_BusinessTemplateWithPath(self, quiet=0, run=run_all_test):
1770 1771
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1772
      message = 'Test Business Template With A Simple Path'
1773 1774 1775
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
1776
    # a simple path
1777
    sequence_string = '\
Aurel's avatar
Aurel committed
1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddBaseCategoryAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
Romain Courteaud's avatar
Romain Courteaud committed
1810 1811
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
1812

Aurel's avatar
Aurel committed
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
  def test_10_BusinessTemplateWithPathAndJoker1(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Path And Joker *'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()    
    # path with subobjects
    sequence_string = '\
                       CreateBaseCategory \
                       CreateCategories \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddCategoriesAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveCategories \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
                       '    
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
1858

Aurel's avatar
Aurel committed
1859
  def test_11_BusinessTemplateWithPathAndJoker2(self, quiet=0, run=run_all_test):
1860 1861
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
1862
      message = 'Test Business Template With Path And Joker **'
1863 1864 1865
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
1866
    # path with subobject recursively
1867
    sequence_string = '\
Aurel's avatar
Aurel committed
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveCategories \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
                       '
1904 1905 1906
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

Aurel's avatar
Aurel committed
1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056
  def test_12_BusinessTemplateWithCatalogMethod(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Catalog Method, Related Key, Result Key And Table'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckKeysAndTableRemoved \
                       CheckCatalogMethodRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

  def test_13_BusinessTemplateWithRole(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Role'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateRole \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddRoleToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveRole \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckRoleExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckRoleRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    

  def test_14_BusinessTemplateWithPropertySheet(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Property Sheet'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPropertySheetRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    


  def test_15_BusinessTemplateWithAllItems(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With All Items'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
2057 2058
                       CreateAction \
                       CreateOptionalAction \
Aurel's avatar
Aurel committed
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddOptionalActionToBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
                       CheckOptionalActionExists \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       CheckModuleRemoved \
                       CheckSkinFolderRemoved \
                       CheckBaseCategoryRemoved \
                       CheckWorkflowRemoved \
                       CheckCatalogMethodRemoved \
                       CheckKeysAndTableRemoved \
                       CheckRoleRemoved \
                       CheckPropertySheetRemoved \
                       CheckSkinsLayers \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    



  def test_16_SubobjectsAfterUpgradOfBusinessTemplate(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Upgrade Of Business Template Keeps Subobjects'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    # check if subobjects in module and catalog still remains after an update
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckModuleObjectsRemoved \
                       CheckBaseCategoryExists \
                       CreateModuleObjects \
                       CreateCategories \
                       CreateSubCategories \
                       CreateNewBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckBaseCategoryExists \
                       CheckModuleObjectsExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       CheckModuleRemoved \
                       CheckBaseCategoryRemoved \
                       CheckSkinsLayers \
                       '    
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_17_upgradeBusinessTemplateWithAllItems(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Upgrade Business Template With All Items'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    # by default action is backup, so everything will be replace
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
2229 2230
                       CreateAction \
                       CreateOptionalAction \
Aurel's avatar
Aurel committed
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddOptionalActionToBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
                       CheckOptionalActionExists \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
                       CheckPropertySheetExists \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
                       CheckOptionalActionExists \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
                       CheckPropertySheetExists \
                       CheckSkinsLayers \
2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
Aurel's avatar
Aurel committed
2324 2325 2326
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    
2327

Aurel's avatar
Aurel committed
2328 2329 2330 2331 2332 2333 2334 2335 2336
  # test specific to erp5_core
  def test_18_checkUpdateBusinessTemplateWorkflow(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Check Update of Business Template Workflows is working'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
                       CreateAction \
                       CreateOptionalAction \
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
2350 2351
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
2352
                       ClearBusinessTemplateField \
Aurel's avatar
Aurel committed
2353
                       SetUpdateWorkflowFlagInBusinessTemplate \
2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddOptionalActionToBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
                       CheckOptionalActionExists \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
                       CheckPropertySheetExists \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
Aurel's avatar
Aurel committed
2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)      


  def test_19_checkUpdateTool(self, quiet=0, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Check Update of Tool is working'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
                       CreateAction \
                       CreateOptionalAction \
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
2433 2434
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
2435
                       ClearBusinessTemplateField \
Aurel's avatar
Aurel committed
2436
                       SetUpdateToolFlagInBusinessTemplate \
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447
                       AddPortalTypeToBusinessTemplate \
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddOptionalActionToBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
2448 2449 2450 2451 2452 2453 2454 2455 2456
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
2457 2458 2459 2460 2461 2462 2463 2464 2465 2466
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
Aurel's avatar
Aurel committed
2467
                       RemoveAllTrashBins \
2468
                       RemoveTrashTool \
Aurel's avatar
Aurel committed
2469 2470 2471 2472 2473 2474 2475 2476
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2477
                       CheckTrashToolExists \
Aurel's avatar
Aurel committed
2478
                       CheckSkinsLayers \
2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
                       CheckOptionalActionExists \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
                       CheckPropertySheetExists \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
Aurel's avatar
Aurel committed
2501 2502 2503 2504
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)      

2505
if __name__ == '__main__':
Aurel's avatar
Aurel committed
2506
  framework()
2507
else:
Aurel's avatar
Aurel committed
2508 2509 2510 2511 2512
  import unittest
  def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(TestBusinessTemplate))
    return suite