testBusinessTemplate.py 203 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
#
# 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.
#
##############################################################################

29
import unittest
30 31 32

from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
Aurel's avatar
Aurel committed
33 34
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_base
35 36
from zLOG import LOG
from Products.ERP5Type.ERP5Type import ERP5TypeInformation
37
from Products.ERP5Type.RoleInformation import RoleInformation
38
from App.config import getConfiguration
Aurel's avatar
Aurel committed
39
from Products.ERP5Type.tests.Sequence import SequenceList
Aurel's avatar
Aurel committed
40
from urllib import pathname2url
Aurel's avatar
Aurel committed
41 42
from Globals import PersistentMapping
from Products.CMFCore.Expression import Expression
Jérome Perrin's avatar
Jérome Perrin committed
43
from Products.CMFCore.tests.base.testcase import LogInterceptor
44
import shutil
Aurel's avatar
Aurel committed
45
import os
46

Jérome Perrin's avatar
Jérome Perrin committed
47
class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
48 49 50 51 52 53 54 55 56 57 58
  """
    Test these operations:

    - Create a template

    - Install a template

    - Uninstall a template

    - Upgrade a template
  """
Romain Courteaud's avatar
Romain Courteaud committed
59
  run_all_test = 1
Jérome Perrin's avatar
Jérome Perrin committed
60
  quiet = 1
61 62

  def getBusinessTemplateList(self):
Aurel's avatar
Aurel committed
63
    return ('erp5_csv_style', 'erp5_pdf_style')
Aurel's avatar
Aurel committed
64

Yoshinori Okuji's avatar
Yoshinori Okuji committed
65 66
  def getTitle(self):
    return "Business Template"
67

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

75 76 77 78
  def afterSetUp(self):
    self.login()
    portal = self.getPortal()
    catalog_tool = self.getCatalogTool()
79
    # create the fake catalog table
80
    sql_connection = self.getSQLConnection()
81 82
    sql = 'create table if not exists `fake_catalog` (`toto` BIGINT)'
    sql_connection.manage_test(sql)
Aurel's avatar
Aurel committed
83
    self._catch_log_errors()
84

85
    # remove default predicate which matches anything
86 87 88
    content_type_registry = getattr(portal, 'content_type_registry', None)
    if (content_type_registry is not None and
        'any' in content_type_registry.predicate_ids):
89 90 91
      content_type_registry.removePredicate('any')
      get_transaction().commit()

Jérome Perrin's avatar
Jérome Perrin committed
92 93
  def beforeTearDown(self):
    """Remove objects created tests."""
94 95 96 97 98 99 100 101
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
        if id != "Geek Object":
          props['chain_%s' % id] = ', '.join(wf_ids)
    pw.manage_changeWorkflows('', props=props)
Jérome Perrin's avatar
Jérome Perrin committed
102 103
    if 'erp5_geek' in self.getSkinsTool().objectIds():
      self.getSkinsTool().manage_delObjects(['erp5_geek'])
104 105 106 107 108 109 110 111 112
      ps = self.getSkinsTool()
      for skin_name, selection in ps.getSkinPaths():
        new_selection = []
        selection = selection.split(',')
        for skin_id in selection:
          if skin_id != 'erp5_geek':
            new_selection.append(skin_id)
        ps.manage_skinLayers(skinpath=tuple(new_selection), 
                             skinname=skin_name, add_skin=1)
Jérome Perrin's avatar
Jérome Perrin committed
113 114 115 116 117 118
    if 'Geek Object' in self.getTypeTool().objectIds():
      self.getTypeTool().manage_delObjects(['Geek Object', 'Geek Module'])
    if 'geek_module' in self.getPortal().objectIds():
      self.getPortal().manage_delObjects(['geek_module'])
    if 'geek_workflow' in self.getWorkflowTool().objectIds():
      self.getWorkflowTool().manage_delObjects(['geek_workflow'])
119 120
    if 'custom_geek_workflow' in self.getWorkflowTool().objectIds():
      self.getWorkflowTool().manage_delObjects(['custom_geek_workflow'])
Jérome Perrin's avatar
Jérome Perrin committed
121
    get_transaction().commit()
Jérome Perrin's avatar
Jérome Perrin committed
122
    self._ignore_log_errors()
123

124 125 126 127 128 129
  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
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
  def stepTic(self,**kw):
    self.tic()

  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
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

  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
176 177 178 179 180 181 182
  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)
183

184 185 186 187 188 189 190 191
  def stepUseSecondBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Define second_export_bt as current bt
    """
    bt = sequence.get('second_export_bt')
    sequence.edit(current_bt=bt)

192 193 194 195 196 197 198
  def stepUseDependencyBusinessTemplate(self, sequence=None,
                                  sequence_list=None, **kw):
    """
      Define dependency_bt as current bt
    """
    bt = sequence.get('dependency_bt')
    sequence.edit(current_bt=bt)
Aurel's avatar
Aurel committed
199 200 201 202 203 204 205 206

  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)
Aurel's avatar
Aurel committed
207

Aurel's avatar
Aurel committed
208
  def stepCheckInstalledInstallationState(self, sequence=None,
209
                                        sequence_list=None, **kw):
Aurel's avatar
Aurel committed
210 211 212 213 214 215 216
    """
    Check if installation state is installed
    """
    bt = sequence.get('current_bt', None)
    self.assertEquals(bt.getInstallationState(), 'installed')

  def stepCheckNotInstalledInstallationState(self, sequence=None,
217
                                        sequence_list=None, **kw):
Aurel's avatar
Aurel committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231
    """
    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')

Aurel's avatar
Aurel committed
232
  def stepCheckModifiedBuildingState(self, sequence=None,
Aurel's avatar
Aurel committed
233 234 235
                                     sequence_list=None, **kw):
    """
    Check if the building state is modified.
236
    """
Aurel's avatar
Aurel committed
237 238 239
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getBuildingState(), 'modified')

Aurel's avatar
Aurel committed
240
  def stepCheckBuiltBuildingState(self, sequence=None,
Aurel's avatar
Aurel committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
                                  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)
Aurel's avatar
Aurel committed
257 258
    self.failUnless(self.getTrashTool() is not None)

Aurel's avatar
Aurel committed
259 260 261 262 263 264 265 266 267 268
  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)
269
        self.failIf('erp5_xhtml_style' not in selection)
Aurel's avatar
Aurel committed
270
      if skin_name == 'Print':
271
        self.failIf('erp5_xhtml_style' in selection)
Aurel's avatar
Aurel committed
272 273 274 275 276
        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)
277
        self.failIf('erp5_xhtml_style' in selection)
Aurel's avatar
Aurel committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
        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
312 313
    """
    pt = self.getTypeTool()
Aurel's avatar
Aurel committed
314
    # create module object portal type
315 316 317
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type,
                                 id='Geek Object',
                                 typeinfo_name='ERP5Type: ERP5 Person',)
Aurel's avatar
Aurel committed
318 319 320 321
    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
322 323 324
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type,
                                 id='Geek Module',
                                 typeinfo_name='ERP5Type: ERP5 Folder')
325 326
    module_type = pt._getOb('Geek Module', None)
    self.failUnless(module_type is not None)
Aurel's avatar
Aurel committed
327
    module_type.filter_content_types = 1
Aurel's avatar
Aurel committed
328
    module_type.allowed_content_types = ('Geek Object',)
329 330 331
    sequence.edit(module_ptype_id=module_type.getId(),
          module_ptype_filter_content_types=module_type.filter_content_types,
          module_ptype_allowed_content_types=module_type.allowed_content_types)
Aurel's avatar
Aurel committed
332 333 334 335 336 337 338 339 340 341

  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', ''))
342
    self.assertEqual(len(ptype_ids), 2)
Aurel's avatar
Aurel committed
343
    bt.edit(template_portal_type_id_list=ptype_ids)
Aurel's avatar
Aurel committed
344
    self.stepFillPortalTypesFields(sequence=sequence, sequence_list=sequence_list, **kw)
Aurel's avatar
Aurel committed
345

346
  def stepAddDuplicatedPortalTypeToBusinessTemplate(self, sequence=None,
347 348 349 350 351 352 353 354 355 356 357
                                                    sequence_list=None, **kw):
    """
    Add duplicated portal type 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', ''))
    self.assertEqual(len(ptype_ids), 1)
    bt.edit(template_portal_type_id_list=ptype_ids)

Aurel's avatar
Aurel committed
358 359
  def stepRemovePortalType(self, sequence=None, sequence_list=None, **kw):
    """
Aurel's avatar
Aurel committed
360
    Remove PortalType
Aurel's avatar
Aurel committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
    """
    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)
380 381 382 383
    self.failUnless(module_type.allowed_content_types,
        sequence.get('module_ptype_allowed_content_types'))
    self.failUnless(module_type.filter_content_types,
        sequence.get('module_ptype_filter_content_types'))
Aurel's avatar
Aurel committed
384
    object_type = pt._getOb(object_id, None)
385
    self.failUnless(object_type is not None)
386

Aurel's avatar
Aurel committed
387 388 389 390 391 392 393 394 395 396 397
  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)
398

399
  def stepCheckDuplicatedPortalTypeRemoved(self, sequence=None,
400 401 402 403 404 405 406 407 408 409
                                           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')
    object_type = pt._getOb(object_id, None)
    self.failUnless(object_type is None)

Aurel's avatar
Aurel committed
410 411 412 413 414 415 416 417
  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()

418 419 420 421 422 423 424 425 426 427 428
  def stepFillWrongPortalTypesFields(self, sequence=None, sequence_list=None, **kw):
    """
    Fill portal types properties field in business template with wrong values
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.getPortalTypesProperties()
    bt_allowed_content_type_list = list(getattr(self, 'template_portal_type_allowed_content_type', []) or [])
    bt_allowed_content_type_list.append("Geek Module | BusinessTemplate")
    bt.setProperty('template_portal_type_allowed_content_type', bt_allowed_content_type_list)
    
Aurel's avatar
Aurel committed
429 430 431 432 433 434 435 436 437 438
  # 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
Aurel's avatar
Aurel committed
439
      id = "%s_%s" %('geek_module', n)
Aurel's avatar
Aurel committed
440 441
    module = portal.newContent(id=id, portal_type='Geek Module')
    self.failUnless(module is not None)
Aurel's avatar
Aurel committed
442 443
    # add a specific permission to module which do not use acquisition
    module.manage_permission('Copy or Move', ['Assignor'], False)
Aurel's avatar
Aurel committed
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
    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
    """
Aurel's avatar
Aurel committed
465
    portal = self.getPortal()
Aurel's avatar
Aurel committed
466 467 468 469 470 471 472 473
    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())
Aurel's avatar
Aurel committed
474
    sequence.edit(module_object_id_list=module_object_list)
Aurel's avatar
Aurel committed
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493

  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)

Aurel's avatar
Aurel committed
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
  def stepCheckModulePermissions(self, sequence=None, sequence_list=None, **kw):
    """
    Check specific permissions defined on module do no get acquired flag
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
    new_module = portal._getOb(module_id, None)
    perms = new_module.permission_settings('Copy or Move')
    self.assertEqual(len(perms), 1)
    # check we do not have acquire
    for perm in perms:
      self.assertEqual(perm['name'], 'Copy or Move')
      self.assertNotEqual(perm['acquire'], 'CHECKED')
    # check permission defined for the right role
    perms = new_module.rolesOfPermission(permission='Copy or Move')
    for perm in perms:
      if perm['name'] == 'Assignor':
        self.assertEqual(perm["selected"], "SELECTED")
      else:
        self.assertNotEqual(perm["selected"], "SELECTED")

Aurel's avatar
Aurel committed
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
  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)
Aurel's avatar
Aurel committed
540

Aurel's avatar
Aurel committed
541 542 543 544 545 546
  def stepCheckModuleRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non presence of module
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
Aurel's avatar
Aurel committed
547
    self.failIf(portal._getOb(module_id, None) is not None)
Aurel's avatar
Aurel committed
548 549 550 551 552 553

  # skins folder
  def stepCreateSkinFolder(self, sequence=None, sequence_list=None, **kw):
    """
    Create a skin folder
    """
554
    ps = self.getSkinsTool()
Aurel's avatar
Aurel committed
555 556
    ps.manage_addProduct['OFSP'].manage_addFolder('erp5_geek')
    skin_folder = ps._getOb('erp5_geek', None)
557
    self.failUnless(skin_folder is not None)
Aurel's avatar
Aurel committed
558 559
    sequence.edit(skin_folder_id=skin_folder.getId())
    # add skin in layers
560 561
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
Aurel's avatar
Aurel committed
562 563
      if 'erp5_geek' not in selection:
        selection.append('erp5_geek')
564
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)
565

566 567 568 569 570 571 572 573
  def stepCreateSkinSubFolder(self, sequence=None, sequence_list=None, **kw):
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.failUnless(skin_folder is not None)
    skin_folder.manage_addFolder('erp5_subgeek')
    skin_subfolder = skin_folder._getOb('erp5_subgeek', None)
    self.failUnless(skin_subfolder is not None)
    sequence.edit(skin_subfolder_id=skin_subfolder.getId())
574

575 576 577 578 579 580 581 582 583 584 585
  def stepCheckSkinSubFolderExists(self, sequence=None,sequence_list=None, **kw):
    """
    Check presence of skin sub 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)
    subskin_id = sequence.get('skin_subfolder_id')
    skin_subfolder = skin_folder._getOb(subskin_id, None)
    self.failUnless(skin_subfolder is not None)
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 620 621 622 623 624 625 626 627 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 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
  def stepCreateNewForm(self, sequence=None, sequence_list=None):
    """Create a new ERP5 Form in a skin folder."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.assertNotEquals(skin_folder, None)
    form_id = 'Geek_view'
    addERP5Form = skin_folder.manage_addProduct['ERP5Form'].addERP5Form
    addERP5Form(form_id, 'View')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
    self.assertEquals(sorted(form.get_groups(include_empty=1)),
                      sorted(['left', 'right', 'center', 'bottom', 'hidden']))
    addField = form.manage_addProduct['Formulator'].manage_addField
    addField('my_title', 'Title', 'StringField')
    field = form.get_field('my_title')
    self.assertEquals(form.get_fields_in_group('left'), [field])
    group_dict = {}
    for group in form.get_groups(include_empty=1):
      id_list = []
      for field in form.get_fields_in_group(group):
        id_list.append(field.getId())
      group_dict[group] = id_list 
    sequence.edit(form_id=form_id, group_dict=group_dict)

  def stepRemoveForm(self, sequence=None, sequence_list=None):
    """Remove an ERP5 Form."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
    skin_folder.manage_delObjects([form_id])
    form = skin_folder._getOb(form_id, None)
    self.assertEquals(form, None)

  def stepAddFormField(self, sequence=None, sequence_list=None):
    """Add a field to an ERP5 Form."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
    self.assertEquals(sorted(form.get_groups(include_empty=1)),
                      sorted(['left', 'right', 'center', 'bottom', 'hidden']))
    addField = form.manage_addProduct['Formulator'].manage_addField
    addField('my_reference', 'Reference', 'StringField')
    form.move_field_group(['my_reference'], 'left', 'right')
    field = form.get_field('my_reference')
    self.assertEquals(form.get_fields_in_group('right'), [field])
    group_dict = {}
    for group in form.get_groups(include_empty=1):
      id_list = []
      for field in form.get_fields_in_group(group):
        id_list.append(field.getId())
      group_dict[group] = id_list 
    sequence.edit(group_dict=group_dict, field_id=field.getId())

  def stepRemoveFormField(self, sequence=None, sequence_list=None):
    """Remove a field from an ERP5 Form."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
    field_id = sequence.get('field_id')
    field = form.get_field(field_id)
    self.assertNotEquals(field, None)
    form.manage_delObjects([field_id])
    self.assertRaises(AttributeError, form.get_field, field_id)

  def stepCheckFormGroups(self, sequence=None, sequence_list=None):
    """Check the groups of an ERP5 Form."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
    group_dict = sequence.get('group_dict')
    self.assertEquals(sorted(form.get_groups(include_empty=1)),
                      sorted(group_dict.iterkeys()))
    for group in group_dict.iterkeys():
      id_list = []
      for field in form.get_fields_in_group(group):
        id_list.append(field.getId())
      self.assertEquals(group_dict[group], id_list)

677 678 679 680 681 682 683 684 685 686 687
  def stepCreateNewObjectInSkinSubFolder(self, sequence=None, sequence_list=None, **kw):
    """
    Create a new object in skin subfolder
    """
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_geek', None)
    self.failUnless(skin_folder is not None)
    skin_subfolder = skin_folder._getOb('erp5_subgeek', None)
    self.failUnless(skin_subfolder is not None)
    method_id = "z_fake_method"
    addSQLMethod = skin_subfolder.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
688 689
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
690 691 692
    zsql_method = skin_subfolder._getOb(method_id, None)
    self.failUnless(zsql_method is not None)
    sequence.edit(zsql_method_id = method_id)
693

Aurel's avatar
Aurel committed
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
  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)
Aurel's avatar
Aurel committed
716
    self.failUnless(skin_folder is not None)
Aurel's avatar
Aurel committed
717 718 719 720 721 722 723 724 725 726 727 728

  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):
    """
729
    Add skin folder to business template
Aurel's avatar
Aurel committed
730 731 732 733 734 735 736
    """
    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)
737

738 739 740 741 742 743 744
  def stepAddPathToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add a path to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_path_list=['geek_path',])
745

Aurel's avatar
Aurel committed
746 747 748 749 750
  # Base Category
  def stepCreateBaseCategory(self, sequence=None, sequence_list=None, **kw):
    """
    Create Base category
    """
751
    pc = self.getCategoryTool()
Aurel's avatar
Aurel committed
752
    base_category = pc.newContent(portal_type = 'Base Category')
753
    self.failUnless(base_category is not None)
754
    sequence.edit(bc_id=base_category.getId(),)
Aurel's avatar
Aurel committed
755

756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
  # Content Type Registry
  def stepAddEntryToContentTypeRegistry(self, sequence=None, sequence_list=None, **kw):
    """
    Add entry to content type registry
    """
    ctr = getattr(self.getPortal(), 'content_type_registry')
    ctr.addPredicate('test', 'extension')
    ctr.assignTypeName('test', 'What Not')
    ctr.getPredicate('test').extensions = ('abc', 'def')

  def stepCheckContentTypeRegistryHasNewEntry(self, sequence=None, sequence_list=None, **kw):
    """
      Check that we can find new type name in ctr
    """
    ctr = getattr(self.getPortal(), 'content_type_registry')
    self.failUnless(ctr.findTypeName('bzzz.def', None, None) == 'What Not')

  def stepAddContentTypeRegistryAsPathToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
      Add Content Type Registry to Business template
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'content_type_registry'
    bt.edit(template_path_list=[path])

  def stepRemoveContentTypeRegistryNewEntry(self, sequence=None, sequence_list=None, **kw):
    """
      Remove new entry from content_type_registry
    """
    ctr = getattr(self.getPortal(), 'content_type_registry')
    ctr.removePredicate('test')

  def stepCheckContentTypeRegistryHasNoNewEntry(self, sequence=None, sequence_list=None, **kw):
    """
      Check that we can not find new type name in ctr anymore
    """
    ctr = getattr(self.getPortal(), 'content_type_registry')
    self.failUnless(ctr.findTypeName('bzzz.def', None, None) is None)

Aurel's avatar
Aurel committed
796 797 798 799 800 801
  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')
802
    bt.edit(template_base_category_list=[bc_id,])
Aurel's avatar
Aurel committed
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820

  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)
Aurel's avatar
Aurel committed
821
    self.failUnless(base_category is None)
Aurel's avatar
Aurel committed
822 823 824 825 826 827 828 829

  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)
Aurel's avatar
Aurel committed
830
    self.failUnless(base_category is not None)
Aurel's avatar
Aurel committed
831 832 833 834 835 836 837 838

  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)
Aurel's avatar
Aurel committed
839
    self.failUnless(base_category is None)
Aurel's avatar
Aurel committed
840

841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
  def stepSaveBaseCategoryUid(self, sequence=None, sequence_list=None, **kw):
    """
    Check uid has not changed after an upgrade
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    sequence.edit(bc_uid = base_category.getUid())

  def stepCheckBaseCategoryUid(self, sequence=None, sequence_list=None, **kw):
    """
    Check uid has not changed after an upgrade
    """
    bc_id = sequence.get('bc_id')
    bc_uid = sequence.get('bc_uid')
    pc = self.getCategoryTool()
    base_category = pc._getOb(bc_id, None)
    self.assertEqual(bc_uid, base_category.getUid())

Aurel's avatar
Aurel committed
860 861 862 863 864 865 866
  # 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()
Aurel's avatar
Aurel committed
867
    base_category = pc._getOb(bc_id, None)
Aurel's avatar
Aurel committed
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
    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)
Aurel's avatar
Aurel committed
924

Aurel's avatar
Aurel committed
925 926 927 928 929 930 931 932 933 934 935 936 937
  # 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)
938
    self.failUnless(category is not None)
Aurel's avatar
Aurel committed
939 940 941 942 943 944
    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())
945

Aurel's avatar
Aurel committed
946 947 948 949 950 951 952 953
  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])
Aurel's avatar
Aurel committed
954

Aurel's avatar
Aurel committed
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
  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)
Aurel's avatar
Aurel committed
970

Aurel's avatar
Aurel committed
971 972 973 974 975
  # workflow
  def stepCreateWorkflow(self, sequence=None, sequence_list=None, **kw):
    """
    Create a workflow
    """
976 977
    pw = self.getWorkflowTool()
    pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', 'geek_workflow')
Aurel's avatar
Aurel committed
978 979 980
    workflow = pw._getOb('geek_workflow', None)
    self.failUnless(workflow is not None)
    sequence.edit(workflow_id=workflow.getId())
981 982 983 984 985
    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)
Christophe Dumez's avatar
Christophe Dumez committed
986
    props['chain_Geek Object'] = 'geek_workflow'
987 988
    pw.manage_changeWorkflows('', props=props)

Christophe Dumez's avatar
Christophe Dumez committed
989 990 991 992 993 994 995 996 997 998
  def stepCheckWorkflowChainRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check if the workflowChain has been removed
    """
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    if cbt is not None:
      for id, wf_ids in cbt.items():
        self.failUnless(id!="Geek Object")

999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
  def stepCheckWorkflowChainExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check if the workflowChain has been removed
    """
    present = 0
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    if cbt is not None:
      for id, wf_ids in cbt.items():
        if id == "Geek Object":
          present = 1
    self.assertEqual(present, 1)

Aurel's avatar
Aurel committed
1012
  def stepAddWorkflowToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
1013
    """
Aurel's avatar
Aurel committed
1014
    Add workflow to business template
1015
    """
Aurel's avatar
Aurel committed
1016 1017 1018 1019 1020 1021
    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)
Aurel's avatar
Aurel committed
1022

Christophe Dumez's avatar
Christophe Dumez committed
1023 1024 1025 1026 1027 1028 1029 1030 1031
  def stepAddWorkflowChainToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add workflow to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    wf_chain_ids = ['Geek Object | %s' % sequence.get('workflow_id', '')]
    bt.edit(template_portal_type_workflow_chain_list=wf_chain_ids)

Aurel's avatar
Aurel committed
1032 1033 1034 1035 1036 1037 1038 1039 1040
  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)
Christophe Dumez's avatar
Christophe Dumez committed
1041 1042 1043 1044 1045
    # remove workflowChain
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
1046 1047 1048 1049
        wf_ids = list(wf_ids)
        if id == "Geek Object":
          wf_ids.remove(wf_id)
        props['chain_%s' % id] = ','.join(wf_ids)
Christophe Dumez's avatar
Christophe Dumez committed
1050
    pw.manage_changeWorkflows('', props=props)
1051

Aurel's avatar
Aurel committed
1052 1053 1054 1055 1056 1057 1058 1059
  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)
1060

Aurel's avatar
Aurel committed
1061 1062 1063 1064 1065 1066 1067 1068
  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)
1069

1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
  def stepCheckWorkflowBackup(self, sequence=None, sequence_list=None, **kw):
    """
    Check workflow and its subobjects has been well backup in portal trash
    """
    wf_id = sequence.get('workflow_id')
    tt = self.getPortal()['portal_trash']
    self.assertEqual(len(tt.objectIds()), 1)
    bin = tt.objectValues()[0]
    self.assertNotEqual(len(bin.portal_workflow_items[wf_id].objectIds()), 0)

Aurel's avatar
Aurel committed
1080
  # Actions
Aurel's avatar
Aurel committed
1081
  def stepCreateFirstAction(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1082
    """
Aurel's avatar
Aurel committed
1083
    Create action
Aurel's avatar
Aurel committed
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
    """
    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
1096
      , priority = 2.0 )
Aurel's avatar
Aurel committed
1097
    sequence.edit(first_action_id='become_geek')
Aurel's avatar
Aurel committed
1098

1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
  def stepCreateEmptyAction(self, sequence=None, sequence_list=None, **kw):
    """
    Create an empty action
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    object_pt.addAction(id = ''
      , name = ' Nerd'
      , action = ''
      , condition = ''
      , permission = ()
      , category = ''
      , visible = 1
      , priority = 1.2)

Aurel's avatar
Aurel committed
1115
  def stepCreateSecondAction(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1116
    """
Aurel's avatar
Aurel committed
1117
    Create a second action
Aurel's avatar
Aurel committed
1118 1119 1120 1121
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1122 1123 1124 1125 1126 1127 1128 1129
    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
1130
      , priority = 1.5 )
Aurel's avatar
Aurel committed
1131
    sequence.edit(second_action_id='become_nerd')
Aurel's avatar
Aurel committed
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145

  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

Aurel's avatar
Aurel committed
1146
  def stepCheckFirstActionExists(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1147
    """
Aurel's avatar
Aurel committed
1148
    Check presence of action
Aurel's avatar
Aurel committed
1149 1150 1151 1152
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1153
    action_id = sequence.get('first_action_id')
Aurel's avatar
Aurel committed
1154
    self.failUnless(action_id in [x.getId() for x in object_pt.listActions()])
1155

Aurel's avatar
Aurel committed
1156
  def stepCheckFirstActionNotExists(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1157
    """
Aurel's avatar
Aurel committed
1158
    Check non-presence of action
Aurel's avatar
Aurel committed
1159 1160 1161 1162
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1163
    action_id = sequence.get('first_action_id')
Aurel's avatar
Aurel committed
1164
    self.failUnless(action_id not in [x.getId() for x in object_pt.listActions()])
1165

Aurel's avatar
Aurel committed
1166
  def stepCheckSecondActionExists(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1167
    """
Aurel's avatar
Aurel committed
1168
    Check presence of the second action
Aurel's avatar
Aurel committed
1169 1170 1171 1172
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1173
    action_id = sequence.get('second_action_id')
Aurel's avatar
Aurel committed
1174
    self.failUnless(action_id in [x.getId() for x in object_pt.listActions()])
1175

Aurel's avatar
Aurel committed
1176
  def stepCheckSecondActionNotExists(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1177
    """
Aurel's avatar
Aurel committed
1178
    Check non-presence of optional action
Aurel's avatar
Aurel committed
1179 1180 1181 1182
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1183
    action_id = sequence.get('second_action_id')
Aurel's avatar
Aurel committed
1184
    self.failUnless(action_id not in [x.getId() for x in object_pt.listActions()])
1185

Aurel's avatar
Aurel committed
1186
  def stepAddSecondActionToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Aurel's avatar
Aurel committed
1187
    """
Aurel's avatar
Aurel committed
1188
    Add Second Action to business template
Aurel's avatar
Aurel committed
1189
    """
Aurel's avatar
Aurel committed
1190 1191
    object_id = sequence.get('object_ptype_id')
    action_id = sequence.get('second_action_id')
Aurel's avatar
Aurel committed
1192 1193
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
Aurel's avatar
Aurel committed
1194
    bt.edit(template_action_path=['%s | %s' %(object_id, action_id)])
Aurel's avatar
Aurel committed
1195

Aurel's avatar
Aurel committed
1196 1197 1198 1199 1200 1201
  # Catalog Method
  def stepCreateCatalogMethod(self, sequence=None, sequence_list=None, **kw):
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
1202
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1203 1204
    self.failUnless(catalog is not None)
    method_id = "z_fake_method"
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1205
    addSQLMethod = catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
1206 1207
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
Aurel's avatar
Aurel committed
1208
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
    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'] = []
Aurel's avatar
Aurel committed
1224

1225 1226 1227 1228 1229
  def stepCreateNewCatalogMethod(self, sequence=None, sequence_list=None, **kw):
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
1230
    catalog = pc.getSQLCatalog()
1231 1232
    method_id = "z_another_fake_method"
    addSQLMethod =catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
1233 1234
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
    zsql_method = catalog._getOb(method_id, None)
    self.failUnless(zsql_method is not None)
    sequence.edit(another_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)

  def stepChangePreviousCatalogMethod(self, sequence=None, sequence_list=None, **kw):
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
1249
    catalog = pc.getSQLCatalog()
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
    method_id = sequence.get('zsql_method_id')
    previous_method = catalog._getOb(method_id,None)
    self.assertEquals(previous_method.title,'')
    previous_method.title='toto'
    self.assertEquals(previous_method.title,'toto')

  def stepCheckCatalogMethodChangeKept(self, sequence=None, sequence_list=None, **kw):
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
1261
    catalog = pc.getSQLCatalog()
1262 1263 1264 1265
    method_id = sequence.get('zsql_method_id')
    previous_method = catalog._getOb(method_id,None)
    self.assertEquals(previous_method.title,'toto')

Aurel's avatar
Aurel committed
1266 1267 1268 1269 1270 1271 1272 1273
  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)
1274 1275 1276
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    bt.edit(template_catalog_method_id_list=[catalog_id+'/'+method_id])
1277

1278 1279 1280 1281 1282 1283 1284 1285 1286
  def stepAddNewCatalogMethodToBusinessTemplate(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)
    another_method_id = sequence.get('another_zsql_method_id', None)
1287 1288 1289 1290
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    bt.edit(template_catalog_method_id_list=[catalog_id+'/'+method_id,
            catalog_id+'/'+another_method_id])
1291

Aurel's avatar
Aurel committed
1292 1293 1294 1295 1296
  def stepCheckCatalogMethodExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of ZSQL Method in catalog
    """
    pc = self.getCatalogTool()
1297
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1298 1299
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
1300
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
1301 1302 1303 1304 1305 1306 1307 1308 1309
    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'], [])
1310

Aurel's avatar
Aurel committed
1311
  def stepCheckCatalogMethodRemoved(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1312
    """
Aurel's avatar
Aurel committed
1313
    Check non-presence of ZSQL Method in catalog
Romain Courteaud's avatar
Romain Courteaud committed
1314
    """
Aurel's avatar
Aurel committed
1315
    pc = self.getCatalogTool()
1316
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1317 1318
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
Aurel's avatar
Aurel committed
1319
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
1320 1321 1322 1323 1324
    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
1325

Aurel's avatar
Aurel committed
1326

Aurel's avatar
Aurel committed
1327
  def stepRemoveCatalogMethod(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1328
    """
Aurel's avatar
Aurel committed
1329
    Remove ZSQL Method from catalog
Romain Courteaud's avatar
Romain Courteaud committed
1330
    """
Aurel's avatar
Aurel committed
1331
    pc = self.getCatalogTool()
1332
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345
    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]
Aurel's avatar
Aurel committed
1346
    self.failUnless(method_id not in catalog.filter_dict.keys())
Romain Courteaud's avatar
Romain Courteaud committed
1347

Aurel's avatar
Aurel committed
1348
  # Related key, Result key and table, and others
Aurel's avatar
Aurel committed
1349
  def stepCreateKeysAndTable(self, sequence=list, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1350
    """
Aurel's avatar
Aurel committed
1351
    Create some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
1352
    """
1353
    # define variables
Aurel's avatar
Aurel committed
1354
    related_key = 'fake_id | category/catalog/z_fake_method'
1355
    result_key = 'catalog.title'
Aurel's avatar
Aurel committed
1356
    result_table = 'fake_catalog'
Aurel's avatar
Aurel committed
1357 1358 1359 1360 1361
    keyword_key = 'fake_keyword'
    full_text_key = 'fake_full_text'
    request_key = 'fake_request'
    multivalue_key = 'fake_multivalue'
    topic_key = 'fake_topic'
1362
    scriptable_key = 'fake_search_text | fake_script_query'
1363 1364
    role_key = 'Foo | catalog.owner'
    local_role_key = 'Bar | catalog.owner'
Aurel's avatar
Aurel committed
1365 1366
    catalog = self.getCatalogTool().getSQLCatalog()
    self.failUnless(catalog is not None)
1367
    # result table
1368 1369 1370 1371 1372
    if result_table not in catalog.sql_search_tables:
      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)
1373
    self.failUnless(result_table in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
1374
    # result key
1375 1376 1377 1378 1379
    if result_key not in catalog.sql_search_result_keys:
      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)
Aurel's avatar
Aurel committed
1380 1381
    self.failUnless(result_key in catalog.sql_search_result_keys)
    # related key
1382 1383 1384 1385 1386
    if related_key not in catalog.sql_catalog_related_keys:
      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)
Aurel's avatar
Aurel committed
1387
    self.failUnless(related_key in catalog.sql_catalog_related_keys)
Aurel's avatar
Aurel committed
1388
    # keyword keys
1389 1390 1391 1392 1393
    if keyword_key not in catalog.sql_catalog_keyword_search_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)
Aurel's avatar
Aurel committed
1394 1395
    self.failUnless(keyword_key in catalog.sql_catalog_keyword_search_keys)
    # full_text keys
1396 1397 1398 1399 1400
    if full_text_key not in catalog.sql_catalog_full_text_search_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)
Aurel's avatar
Aurel committed
1401 1402
    self.failUnless(full_text_key in catalog.sql_catalog_full_text_search_keys)
    # request
1403 1404 1405 1406 1407
    if request_key not in catalog.sql_catalog_request_keys:
      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)
Aurel's avatar
Aurel committed
1408 1409
    self.failUnless(request_key in catalog.sql_catalog_request_keys)
    # multivalue
1410 1411 1412 1413 1414
    if multivalue_key not in catalog.sql_catalog_multivalue_keys:
      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)
Aurel's avatar
Aurel committed
1415 1416
    self.failUnless(multivalue_key in catalog.sql_catalog_multivalue_keys)
    # topic keys
1417 1418 1419 1420 1421
    if topic_key not in catalog.sql_catalog_topic_search_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)
Aurel's avatar
Aurel committed
1422
    self.failUnless(topic_key in catalog.sql_catalog_topic_search_keys)
1423 1424 1425 1426 1427 1428 1429
    # scriptable keys
    if scriptable_key not in catalog.sql_catalog_scriptable_keys:
      sql_catalog_scriptable_keys = list(catalog.sql_catalog_scriptable_keys)
      sql_catalog_scriptable_keys.append(scriptable_key)
      sql_catalog_scriptable_keys.sort()
      catalog.sql_catalog_scriptable_keys = tuple(sql_catalog_scriptable_keys)
    self.failUnless(scriptable_key in catalog.sql_catalog_scriptable_keys)
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
    # role keys
    if role_key not in catalog.sql_catalog_role_keys:
      sql_catalog_role_keys = list(catalog.sql_catalog_role_keys)
      sql_catalog_role_keys.append(role_key)
      sql_catalog_role_keys.sort()
      catalog.sql_catalog_role_keys = tuple(sql_catalog_role_keys)
    self.failUnless(role_key in catalog.sql_catalog_role_keys)
    # local_role keys
    if local_role_key not in catalog.sql_catalog_local_role_keys:
      sql_catalog_local_role_keys = list(catalog.sql_catalog_local_role_keys)
      sql_catalog_local_role_keys.append(local_role_key)
      sql_catalog_local_role_keys.sort()
      catalog.sql_catalog_local_role_keys = tuple(sql_catalog_local_role_keys)
    self.failUnless(local_role_key in catalog.sql_catalog_local_role_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,
1449
                  multivalue_key=multivalue_key, topic_key=topic_key, \
1450 1451
                  scriptable_key=scriptable_key,
                  role_key=role_key, local_role_key=local_role_key)
Aurel's avatar
Aurel committed
1452

1453 1454 1455 1456 1457
  def stepModifyCatalogConfiguration(self, sequence, **kw):
    """Modify the current configuration of the catalog.
    """
    catalog = self.getCatalogTool().getSQLCatalog()
    # modify method related configuration
1458 1459 1460 1461 1462 1463 1464 1465
    copy_data = catalog.manage_copyObjects(ids=["z_getitem_by_uid"])
    ids = catalog.manage_pasteObjects(copy_data)
    new_id = ids[0]['new_id']    
    new_method = catalog._getOb(new_id)
    catalog.manage_renameObjects([new_id,], ["z_getitem_by_uid_2",])
    new_method = catalog._getOb("z_getitem_by_uid_2")
    self.assertNotEqual(new_method, None)
    catalog.sql_getitem_by_uid = 'z_getitem_by_uid_2'
1466 1467 1468 1469
    # modify table related configuration
    catalog.sql_search_tables = tuple( list(catalog.sql_search_tables) +
                                     ['translation'] )
    # modify column related configuration
1470 1471 1472
    catalog.sql_search_result_keys = tuple( list(catalog.sql_search_result_keys) +
                                     ['catalog.reference'] )
    sequence.edit(result_key='catalog.reference', search_table="translation")
1473 1474 1475 1476 1477 1478 1479

  def stepCheckCatalogConfigurationKept(self, sequence, **kw):
    """Check modification made in stepModifyCatalogConfiguration are still
    present.
    """
    catalog = self.getCatalogTool().getSQLCatalog()
    # method related configuration
1480
    self.assertEquals(catalog.sql_getitem_by_uid, 'z_getitem_by_uid_2')
1481 1482 1483
    # table related configuration
    self.failUnless('translation' in catalog.sql_search_tables)
    # column related configuration
1484
    self.failUnless('catalog.reference'
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
                    in catalog.sql_search_result_keys)

  def stepRemoveCatalogLocalConfiguration(self, sequence, **kw):
    """
    Remove modification made in stepModifyCatalogConfiguration
    """
    result_key = sequence.get('result_key', None)
    self.failUnless(result_key is not None)
    result_table = sequence.get('search_table', None)
    self.failUnless(result_table is not None)
    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.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)
    # search 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)
1509

Aurel's avatar
Aurel committed
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521
  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
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531
    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)
1532 1533
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1534 1535 1536 1537
    role_key = sequence.get('role_key', None)
    self.failUnless(role_key is not None)
    local_role_key = sequence.get('local_role_key', None)
    self.failUnless(local_role_key is not None)
Aurel's avatar
Aurel committed
1538

Aurel's avatar
Aurel committed
1539 1540
    bt.edit(template_catalog_related_key_list=[related_key],
            template_catalog_result_key_list=[result_key],
Aurel's avatar
Aurel committed
1541 1542 1543 1544 1545 1546
            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],
1547
            template_catalog_scriptable_key_list=[scriptable_key],
1548 1549
            template_catalog_role_key_list=[role_key],
            template_catalog_local_role_key_list=[local_role_key],
Aurel's avatar
Aurel committed
1550
            )
Romain Courteaud's avatar
Romain Courteaud committed
1551

Aurel's avatar
Aurel committed
1552
  def stepRemoveKeysAndTable(self, sequence=list, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1553
    """
Aurel's avatar
Aurel committed
1554
    Remove some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
1555
    """
Aurel's avatar
Aurel committed
1556 1557 1558 1559 1560 1561
    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
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571
    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)
1572 1573
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1574 1575 1576 1577
    role_key = sequence.get('role_key', None)
    self.failUnless(role_key is not None)
    local_role_key = sequence.get('local_role_key', None)
    self.failUnless(local_role_key is not None)
Aurel's avatar
Aurel committed
1578

Aurel's avatar
Aurel committed
1579
    catalog = self.getCatalogTool().getSQLCatalog()
Aurel's avatar
Aurel committed
1580
    self.failUnless(catalog is not None)
Aurel's avatar
Aurel committed
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598
    # 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
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
    # 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)
1629 1630 1631 1632 1633 1634
    # scriptable keys
    sql_catalog_scriptable_keys = list(catalog.sql_catalog_scriptable_keys)
    sql_catalog_scriptable_keys.remove(scriptable_key)
    sql_catalog_scriptable_keys.sort()
    catalog.sql_catalog_scriptable_keys = tuple(sql_catalog_scriptable_keys)
    self.failUnless(scriptable_key not in catalog.sql_catalog_scriptable_keys)
1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
    # role keys
    sql_catalog_role_keys = list(catalog.sql_catalog_role_keys)
    sql_catalog_role_keys.remove(role_key)
    sql_catalog_role_keys.sort()
    catalog.sql_catalog_role_keys = tuple(sql_catalog_role_keys)
    self.failUnless(role_key not in catalog.sql_catalog_role_keys)
    # local_role keys
    sql_catalog_local_role_keys = list(catalog.sql_catalog_local_role_keys)
    sql_catalog_local_role_keys.remove(local_role_key)
    sql_catalog_local_role_keys.sort()
    catalog.sql_catalog_local_role_keys = tuple(sql_catalog_local_role_keys)
    self.failUnless(local_role_key not in catalog.sql_catalog_local_role_keys)
Aurel's avatar
Aurel committed
1647

Romain Courteaud's avatar
Romain Courteaud committed
1648

Aurel's avatar
Aurel committed
1649
  def stepCheckKeysAndTableExists(self, sequence=list, sequence_list=None, **kw):
1650
    """
Aurel's avatar
Aurel committed
1651
    Check presence of some keys and tables
1652
    """
Aurel's avatar
Aurel committed
1653 1654 1655 1656 1657 1658
    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
1659 1660 1661 1662 1663 1664 1665 1666 1667 1668
    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)
1669 1670
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1671 1672 1673 1674
    role_key = sequence.get('role_key', None)
    self.failUnless(role_key is not None)
    local_role_key = sequence.get('local_role_key', None)
    self.failUnless(local_role_key is not None)
Aurel's avatar
Aurel committed
1675

Aurel's avatar
Aurel committed
1676 1677 1678 1679 1680 1681 1682 1683
    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
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
    # 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)
1694 1695
    # scriptable key
    self.failUnless(scriptable_key in catalog.sql_catalog_scriptable_keys)
1696 1697 1698 1699
    # role key
    self.failUnless(role_key in catalog.sql_catalog_role_keys)
    # local_role key
    self.failUnless(local_role_key in catalog.sql_catalog_local_role_keys)
1700

Aurel's avatar
Aurel committed
1701
  def stepCheckKeysAndTableRemoved(self, sequence=list, sequence_list=None, **kw):
1702
    """
Aurel's avatar
Aurel committed
1703
    Check non-presence of some keys and tables
1704
    """
Aurel's avatar
Aurel committed
1705 1706 1707 1708 1709 1710
    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
1711 1712 1713 1714 1715 1716 1717 1718 1719 1720
    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)
1721 1722
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1723 1724 1725 1726
    role_key = sequence.get('role_key', None)
    self.failUnless(role_key is not None)
    local_role_key = sequence.get('local_role_key', None)
    self.failUnless(local_role_key is not None)
Aurel's avatar
Aurel committed
1727

Aurel's avatar
Aurel committed
1728 1729 1730 1731 1732 1733 1734 1735
    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
1736 1737 1738 1739 1740 1741 1742 1743 1744 1745
    # 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)
1746 1747
    # scriptable key
    self.failUnless(scriptable_key not in catalog.sql_catalog_scriptable_keys)
1748 1749 1750 1751
    # role key
    self.failUnless(role_key not in catalog.sql_catalog_role_keys)
    # local_role key
    self.failUnless(local_role_key not in catalog.sql_catalog_local_role_keys)
1752

Aurel's avatar
Aurel committed
1753 1754
  # Roles
  def stepCreateRole(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1755
    """
Aurel's avatar
Aurel committed
1756
    Create a role
Romain Courteaud's avatar
Romain Courteaud committed
1757
    """
Aurel's avatar
Aurel committed
1758 1759 1760 1761 1762 1763 1764
    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
1765

Aurel's avatar
Aurel committed
1766
  def stepRemoveRole(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1767
    """
Aurel's avatar
Aurel committed
1768
    Remove a role
Romain Courteaud's avatar
Romain Courteaud committed
1769
    """
Aurel's avatar
Aurel committed
1770 1771 1772 1773 1774 1775 1776
    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
1777

Aurel's avatar
Aurel committed
1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
  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__)
Aurel's avatar
Aurel committed
1796

Aurel's avatar
Aurel committed
1797
  def stepCheckRoleRemoved(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1798
    """
Aurel's avatar
Aurel committed
1799
    Check non-presence of role
Romain Courteaud's avatar
Romain Courteaud committed
1800
    """
Aurel's avatar
Aurel committed
1801 1802 1803 1804
    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
1805

Aurel's avatar
Aurel committed
1806 1807 1808 1809 1810 1811 1812
  # Local Roles
  def stepCreateLocalRoles(self, sequence=None, sequence_list=None, **kw):
    """
    Create local roles
    """
    new_local_roles = {'ac':['Owner', 'Manager']}
    new_local_group_roles = {'role:Authenticated':['Owner', 'Manager']}
Aurel's avatar
Aurel committed
1813
    p = self.getPortal()
Aurel's avatar
Aurel committed
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    module.__ac_local_roles__ = new_local_roles
    module.__ac_local_group_roles__ = new_local_group_roles
    self.assertEquals(module.__ac_local_roles__, new_local_roles)
    self.assertEquals(module.__ac_local_group_roles__, new_local_group_roles)
    sequence.edit(local_roles=new_local_roles, local_group_roles=new_local_group_roles)

  def stepRemoveLocalRoles(self, sequence=None, sequence_list=None, **kw):
    """
    Remove local roles
    """
Aurel's avatar
Aurel committed
1827
    p = self.getPortal()
Aurel's avatar
Aurel committed
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 1858
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    module.__ac_local_roles__ = {}
    module.__ac_local_group_roles__ = {}
    new_local_roles = sequence.get('local_roles')
    new_local_group_roles = sequence.get('local_group_roles')
    self.assertNotEquals(module.__ac_local_roles__, new_local_roles)
    self.assertNotEquals(module.__ac_local_group_roles__, new_local_group_roles)

  def stepAddLocalRolesToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Local Roles to Business Template
    """
    module_id = sequence.get('module_id')
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_local_roles_list=[module_id])

  def stepCheckLocalRolesExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check presence of local roles
    """
    new_local_roles = sequence.get('local_roles')
    new_local_group_roles = sequence.get('local_group_roles')
    p = self.getPortal()
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    self.assertEquals(module.__ac_local_roles__, new_local_roles)
    self.assertEquals(module.__ac_local_group_roles__, new_local_group_roles)
Aurel's avatar
Aurel committed
1859

Aurel's avatar
Aurel committed
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872
  def stepCheckLocalRolesRemoved(self, sequence=None, sequence_list=None, **kw):
    """
    Check non-presence of local roles
    """
    new_local_roles = sequence.get('local_roles')
    new_local_group_roles = sequence.get('local_group_roles')
    p = self.getPortal()
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    self.assertNotEquals(module.__ac_local_roles__, new_local_roles)
    self.assertNotEquals(module.__ac_local_group_roles__, new_local_group_roles)

Aurel's avatar
Aurel committed
1873 1874 1875
  # 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
1876
    """
Aurel's avatar
Aurel committed
1877
    Create a Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
1878
    """
Aurel's avatar
Aurel committed
1879 1880 1881
    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
1882
    cfg = getConfiguration()
Aurel's avatar
Aurel committed
1883 1884 1885 1886 1887 1888 1889
    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))
1890
    sequence.edit(ps_title=ps_title, ps_path=file_path, ps_data=ps_data)
Romain Courteaud's avatar
Romain Courteaud committed
1891

Aurel's avatar
Aurel committed
1892
  def stepAddPropertySheetToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1893
    """
Aurel's avatar
Aurel committed
1894
    Add Property Sheet to Business Template
Romain Courteaud's avatar
Romain Courteaud committed
1895
    """
Aurel's avatar
Aurel committed
1896 1897 1898 1899 1900
    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
1901

Aurel's avatar
Aurel committed
1902
  def stepRemovePropertySheet(self, sequence=None, sequencer_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1903
    """
Aurel's avatar
Aurel committed
1904
    Remove Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
1905
    """
Aurel's avatar
Aurel committed
1906 1907 1908 1909 1910
    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))
1911

Aurel's avatar
Aurel committed
1912 1913 1914 1915 1916
  def stepCheckPropertySheetExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Property Sheet
    """
    ps_path = sequence.get('ps_path', None)
1917
    ps_data = sequence.get('ps_data', None)
Aurel's avatar
Aurel committed
1918 1919
    self.failUnless(ps_path is not None)
    self.failUnless(os.path.exists(ps_path))
1920 1921 1922 1923
    # check data in property sheet
    f = file(ps_path, 'r')
    data = f.read()
    self.assertEqual(data, ps_data)
1924

Aurel's avatar
Aurel committed
1925
  def stepCheckPropertySheetRemoved(self, sequence=None, sequencer_list=None, **kw):
1926
    """
Aurel's avatar
Aurel committed
1927 1928 1929 1930 1931
    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))
Aurel's avatar
Aurel committed
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
  def stepCreateUpdatedPropertySheet(self, sequence=None, sequence_list=None, **kw):
    """
    Create a Property Sheet
    """
    ps_title = 'UnitTest'
    ps_data =  ' \nclass UnitTest2: \n  """ \n  Second Fake property sheet for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
    cfg = getConfiguration()
    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_data_u=ps_data)

  def stepCheckUpdatedPropertySheetExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Property Sheet
    """
    ps_path = sequence.get('ps_path', None)
    ps_data = sequence.get('ps_data_u', None)
    self.failUnless(ps_path is not None)
    self.failUnless(os.path.exists(ps_path))
    # check data in property sheet
    f = file(ps_path, 'r')
    data = f.read()
    self.assertEqual(data, ps_data)

Aurel's avatar
Aurel committed
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
  # Test Constraint
  def stepCreateConstraint(self, sequence=None, sequence_list=None, **kw):
    """
    Create a Constraint
    """
    ct_title = 'UnitTest'
    ct_data =  ' \nclass UnitTest: \n  """ \n  Fake constraint for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
    cfg = getConfiguration()
    file_path = os.path.join(cfg.instancehome, 'Constraint', ct_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(ct_data)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(ct_title=ct_title, ct_path=file_path, ct_data=ct_data)

  def stepAddConstraintToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Add Constraint to Business Template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    ct_title = sequence.get('ct_title', None)
    self.failUnless(ct_title is not None)
    bt.edit(template_constraint_id_list=[ct_title])

  def stepRemoveConstraint(self, sequence=None, sequencer_list=None, **kw):
    """
    Remove Constraint
    """
    ct_path = sequence.get('ct_path', None)
    self.failUnless(ct_path is not None)
    self.failUnless(os.path.exists(ct_path))
    os.remove(ct_path)
    self.failIf(os.path.exists(ct_path))

  def stepCheckConstraintExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Constraint
    """
    ct_path = sequence.get('ct_path', None)
    ct_data = sequence.get('ct_data', None)
    self.failUnless(ct_path is not None)
    self.failUnless(os.path.exists(ct_path))
    # check data in property sheet
    f = file(ct_path, 'r')
    data = f.read()
    self.assertEqual(data, ct_data)
2013

Aurel's avatar
Aurel committed
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
  def stepCheckConstraintRemoved(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Constraint
    """
    ct_path = sequence.get('ct_path', None)
    self.failUnless(ct_path is not None)
    self.failIf(os.path.exists(ct_path))

  def stepCreateUpdatedConstraint(self, sequence=None, sequence_list=None, **kw):
    """
    Create a Constraint
    """
    ct_title = 'UnitTest'
    ct_data =  ' \nclass UnitTest2: \n  """ \n  Second Fake constraint for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
    cfg = getConfiguration()
    file_path = os.path.join(cfg.instancehome, 'Constraint', ct_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(ct_data)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(ct_data_u=ct_data)

  def stepCheckUpdatedConstraintExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Constraint
    """
    ct_path = sequence.get('ct_path', None)
    ct_data = sequence.get('ct_data_u', None)
    self.failUnless(ct_path is not None)
    self.failUnless(os.path.exists(ct_path))
    # check data in property sheet
    f = file(ct_path, 'r')
    data = f.read()
    self.assertEqual(data, ct_data)

Aurel's avatar
Aurel committed
2052 2053
  # Busines templates
  def stepImportBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
2054
    """
Aurel's avatar
Aurel committed
2055 2056 2057
    Import Business Template from a dir
    """
    template_path = sequence.get('template_path')
2058
    template_tool = self.getTemplateTool()
Aurel's avatar
Aurel committed
2059 2060 2061 2062
    exported_bt_id = sequence.get('export_bt').getId()
    import_id = 'imported_%s' %exported_bt_id
    n = 0
    while import_id in template_tool.objectIds():
Aurel's avatar
Aurel committed
2063
      n = n + 1
Aurel's avatar
Aurel committed
2064 2065 2066 2067 2068 2069
      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)
Aurel's avatar
Aurel committed
2070

2071 2072 2073 2074 2075 2076
  def stepAddExtraSlashesToTemplatePath(self, sequence=None, sequence_list=None, **kw):
    """Add extra slashes to the template path for testing.
    """
    template_path = sequence.get('template_path')
    sequence.edit(template_path = template_path + '//')

Aurel's avatar
Aurel committed
2077 2078 2079 2080 2081 2082
  def stepInstallBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Install importzed business template
    """
    import_bt = sequence.get('import_bt')
    import_bt.install(force=1)
2083

2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103
  def stepInstallWithoutForceBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Install importzed business template
    """
    import_bt = sequence.get('import_bt')
    object_list = import_bt.preinstall()
    install_object_dict = {}
    for obj in object_list.keys():
      state = object_list[obj][0]
      if state == 'Removed':
        install_state = 'save_and_remove'
      elif state == 'Modified':
        install_state = 'backup'
      elif state == 'New':
        install_state = 'install'
      else:
        install_state = ""
      install_object_dict[obj] = install_state
    import_bt.install(force=0, object_to_update=install_object_dict)

2104
  def stepInstallDuplicatedBusinessTemplate(self, sequence=None,
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114
                                            sequence_list=None, **kw):
    """
    Install importzed business template
    """
    import_bt = sequence.get('import_bt')
    pt_id = sequence.get('object_ptype_id')
    object_to_update = {
      'portal_types/%s' % pt_id: 'install'}
    import_bt.install(object_to_update=object_to_update)

2115 2116 2117 2118 2119
  def stepPartialCatalogMethodInstall(self, sequence=None, sequence_list=None, **kw):
    """
    Install importzed business template
    """
    import_bt = sequence.get('import_bt')
2120 2121 2122
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    object_to_update = {'portal_catalog/'+catalog_id+'/z_another_fake_method':'install'}
2123 2124
    import_bt.install(object_to_update=object_to_update)

Aurel's avatar
Aurel committed
2125
  def stepCreateNewBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
2126
    """
Aurel's avatar
Aurel committed
2127
    Create a new Business Template
2128
    """
Aurel's avatar
Aurel committed
2129 2130 2131 2132 2133 2134 2135 2136
    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)
2137

2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150
  def stepCreateSecondBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Create a second Business Template
    """
    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='2.0',
                  description='bt for unit_test')
    sequence.edit(second_export_bt=template)

2151
  def stepCreateDuplicatedBusinessTemplate(self, sequence=None,
2152
                                           sequence_list=None, **kw):
2153
    """
2154 2155
    Create a new Business Template which will duplicate
    the configuration.
2156
    """
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167
    pt = self.getTemplateTool()
    template = pt.newContent(portal_type='Business Template')
    self.failUnless(template.getBuildingState() == 'draft')
    self.failUnless(template.getInstallationState() == 'not_installed')
    template.edit(title='duplicated geek template',
                  version='1.0',
                  description='bt for unit_test')
    sequence.edit(
        export_bt=template,
        previous_bt=sequence.get('current_bt'))

2168 2169 2170 2171 2172 2173 2174
  def stepBuildBusinessTemplateFail(self, sequence=None, sequence_list=None, **kw):
    """
    Build Business Template
    """
    template = sequence.get('current_bt')
    self.assertRaises(AttributeError,
                      template.build)
2175

2176 2177 2178 2179 2180 2181 2182 2183
  def stepCheckBuildWithBadPortalTypeFailed(self, sequence=None, sequence_list=None, **kw):
    """
    Build Business Template
    """
    template = sequence.get('current_bt')
    self.assertRaises(ValueError,
                      template.build)

Aurel's avatar
Aurel committed
2184
  def stepBuildBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
2185
    """
Aurel's avatar
Aurel committed
2186
    Build Business Template
2187
    """
Aurel's avatar
Aurel committed
2188
    template = sequence.get('current_bt')
Aurel's avatar
Aurel committed
2189
    template.build()
Romain Courteaud's avatar
Romain Courteaud committed
2190

2191 2192 2193 2194 2195 2196 2197
  def stepEditBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Edit Business Template
    """
    template = sequence.get('current_bt')
    template.edit()

Aurel's avatar
Aurel committed
2198
  def stepSaveBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
Yoshinori Okuji's avatar
Yoshinori Okuji committed
2199
    """
Aurel's avatar
Aurel committed
2200
    Export Business Template
Yoshinori Okuji's avatar
Yoshinori Okuji committed
2201
    """
Aurel's avatar
Aurel committed
2202 2203 2204 2205
    template = sequence.get('current_bt')
    cfg = getConfiguration()
    bt_title = pathname2url(template.getTitle())
    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (bt_title,))
2206
    # remove previous version of bt it exists
2207 2208
    if os.path.exists(template_path):
      shutil.rmtree(template_path)
Aurel's avatar
Aurel committed
2209 2210 2211
    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
2212

Aurel's avatar
Aurel committed
2213
  def stepCheckObjectPropertiesInBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
2214
    """
Aurel's avatar
Aurel committed
2215
    Check that ac_local_roles, uid and _owner are set to None
2216
    """
Aurel's avatar
Aurel committed
2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236
    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)
2237

2238 2239 2240 2241
  def stepCheckUnindexActivityPresence(self, sequence=None, sequence_list=None, **kw):
    """
    Check if we have activity for unindex
    """
2242 2243 2244 2245
    message_list = [ m for m in self.portal.portal_activities.getMessageList()
                     if m.method_id == 'unindexObject'
                     and m.kw.get('uid') is not None ]
    self.assertEquals(len(message_list), 0)
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262

  def stepCheckPathNotUnindexAfterBuild(self, sequence=None, sequence_list=None, **kw):
    """
    Check that after a build, not unindex has been done
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'portal_categories/'+bc_id
    category_id_list = sequence.get('category_id_list')
    portal = self.getPortal()
    ob = portal.unrestrictedTraverse(path)
    self.failUnless(ob is not None)
    for id_ in category_id_list:
      cat = ob[id_]
      catalog_ob_list = [x.getObject() for x in portal.portal_catalog(uid=cat.getUid())]
      self.failUnless(len(catalog_ob_list) > 0)

Aurel's avatar
Aurel committed
2263 2264
  def stepSetUpdateWorkflowFlagInBusinessTemplate(self, sequence=None, sequence_list=None):
    """
Aurel's avatar
Aurel committed
2265
    Set flag for update in Business Template
Aurel's avatar
Aurel committed
2266 2267 2268 2269 2270 2271 2272 2273 2274
    """
    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):
    """
Aurel's avatar
Aurel committed
2275
    Set flag for update in Business Template
Aurel's avatar
Aurel committed
2276 2277 2278 2279 2280 2281 2282
    """
    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
2283
  def stepRemoveBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
2284
    """
Aurel's avatar
Aurel committed
2285
    Remove current Business Template
2286
    """
Aurel's avatar
Aurel committed
2287 2288 2289 2290 2291 2292 2293
    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
2294
    """
Aurel's avatar
Aurel committed
2295
    Uninstall current Business Template
Romain Courteaud's avatar
Romain Courteaud committed
2296
    """
Aurel's avatar
Aurel committed
2297 2298 2299
    bt = sequence.get('current_bt')
    bt.uninstall()

2300
  def stepUninstallPreviousBusinessTemplate(self, sequence=None,
2301 2302 2303 2304 2305 2306 2307
                                            sequence_list=None, **kw):
    """
    Uninstall current Business Template
    """
    bt = sequence.get('previous_bt')
    bt.uninstall()

2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327
  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)

2328
  def stepRemoveSimulationTool(self, sequence=None, sequence_list=None, **kw):
2329 2330 2331 2332
    """
    Remove Trash Tool from site
    """
    p = self.getPortal()
2333 2334
    p.manage_delObjects(['portal_simulation'])
    self.failUnless(p._getOb('portal_simulation', None) is None)
2335

2336
  def stepCheckSimulationToolExists(self, sequence=None, sequence_list=None, **kw):
2337 2338 2339
    """
    Check presence of trash tool
    """
2340
    self.failUnless(self.getSimulationTool() is not None)
Aurel's avatar
Aurel committed
2341

2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352
  def stepCheckSubobjectsNotIncluded(self, sequence=None,
                                     sequence_list=None, **kw):
    """Check subobjects are not included in the base category.
    """
    base_category_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    # XXX maybe too low level
    base_category_obj = bt._category_item._objects.get(
        'portal_categories/%s' % base_category_id)
    self.failUnless(base_category_obj is not None)
    self.assertEquals(len(base_category_obj.objectIds()), 0)
2353

2354 2355 2356
  def stepCheckInitialRevision(self, sequence=None, sequence_list=None, **kw):
    """ Check if revision of a new bt is an empty string
    """
2357
    bt = sequence.get('current_bt')
2358
    self.assertEqual(bt.getRevision(), '')
2359

2360 2361 2362
  def stepCheckFirstRevision(self, sequence=None, sequence_list=None, **kw):
    """ Check if revision of the bt is 1
    """
2363
    bt = sequence.get('current_bt')
2364
    self.assertEqual(bt.getRevision(), '1')
2365

2366 2367 2368
  def stepCheckSecondRevision(self, sequence=None, sequence_list=None, **kw):
    """ Check if revision of the bt is 2
    """
2369
    bt = sequence.get('current_bt')
2370
    self.assertEqual(bt.getRevision(), '2')
2371

2372 2373 2374 2375 2376 2377 2378 2379 2380 2381
  def stepCheckNoMissingDependencies(self, sequence=None, sequence_list=None, **kw):
    """ Check if bt has no missing dependency
    """
    missing_dep = False
    bt = sequence.get('current_bt')
    try:
      bt.checkDependencies()
    except:
      missing_dep = True
    self.failUnless(not missing_dep)
2382

2383 2384 2385 2386 2387 2388 2389 2390 2391 2392
  def stepCheckMissingDependencies(self, sequence=None, sequence_list=None, **kw):
    """ Check if bt has missing dependency
    """
    missing_dep = False
    bt = sequence.get('current_bt')
    try:
      bt.checkDependencies()
    except:
      missing_dep = True
    self.failUnless(missing_dep)
2393

2394 2395 2396 2397 2398
  def stepAddDependency(self, sequence=None, sequence_list=None, **kw):
    """ Add a dependency to the business template
    """
    bt = sequence.get('current_bt')
    bt.setDependencyList(['dependency_bt',])
2399

2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411
  def stepCreateDependencyBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
      Create a new Business Template
    """
    pt = self.getTemplateTool()
    template = pt.newContent(portal_type='Business Template')
    self.failUnless(template.getBuildingState() == 'draft')
    self.failUnless(template.getInstallationState() == 'not_installed')
    template.edit(title='dependency_bt',
                  version='1.0',
                  description='bt for unit_test')
    sequence.edit(dependency_bt=template)
2412

Aurel's avatar
Aurel committed
2413
  # tests
2414 2415 2416 2417
  def test_Title(self):
    """Tests the Title of the Template Tool."""
    self.assertEquals('Template Tool', self.getTemplateTool().Title())

Jérome Perrin's avatar
Jérome Perrin committed
2418
  def test_01_checkNewSite(self, quiet=quiet, run=run_all_test):
Romain Courteaud's avatar
Romain Courteaud committed
2419 2420
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2421
      message = 'Test Check New Site'
Romain Courteaud's avatar
Romain Courteaud committed
2422 2423 2424 2425
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
2426 2427 2428 2429 2430 2431
                       UseCoreBusinessTemplate  \
                       CheckTools \
                       CheckBuiltBuildingState \
                       CheckInstalledInstallationState \
                       CheckSkinsLayers \
                       '
2432
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2433
    sequence_list.play(self, quiet=quiet)
2434

Aurel's avatar
Aurel committed
2435
  # test of portal types
Jérome Perrin's avatar
Jérome Perrin committed
2436
  def test_02_BusinessTemplateWithPortalTypes(self, quiet=quiet, run=run_all_test):
2437 2438
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2439
      message = 'Test Business Template With Portal Types'
2440 2441 2442 2443
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
2444 2445 2446 2447
                       CreatePortalType \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
2448
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2469
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2470 2471 2472 2473 2474 2475 2476
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
2477
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2478
    sequence_list.play(self, quiet=quiet)
2479

2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504
  def test_021_BusinessTemplateWithPortalTypesAdnWrongValues(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Portal Types and Bad Values'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       FillWrongPortalTypesFields \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBuildWithBadPortalTypeFailed \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)


Aurel's avatar
Aurel committed
2505
  # test of skins
Jérome Perrin's avatar
Jérome Perrin committed
2506
  def test_03_BusinessTemplateWithSkins(self, quiet=quiet, run=run_all_test):
2507 2508
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2509
      message = 'Test Business Template With Skin Folder'
2510 2511 2512 2513
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
Aurel's avatar
Aurel committed
2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537
                       CreateSkinFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveSkinFolder \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2538
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2539 2540 2541 2542 2543 2544 2545
                       CheckSkinsLayers \
                       CheckSkinFolderExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSkinFolderRemoved \
                       '
2546
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2547
    sequence_list.play(self, quiet=quiet)
2548

Aurel's avatar
Aurel committed
2549
  # test of workflow
Jérome Perrin's avatar
Jérome Perrin committed
2550
  def test_04_BusinessTemplateWithWorkflow(self, quiet=quiet, run=run_all_test):
2551 2552
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2553
      message = 'Test Business Template With Workflow'
2554 2555 2556 2557
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
2558
                       CreatePortalType \
Aurel's avatar
Aurel committed
2559 2560 2561 2562
                       CreateWorkflow \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
2563
                       AddWorkflowChainToBusinessTemplate \
Aurel's avatar
Aurel committed
2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2584
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2585 2586 2587 2588 2589 2590 2591 2592
                       CheckSkinsLayers \
                       CheckWorkflowExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckWorkflowRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2593
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
2594

2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661
  def test_041_BusinessTemplateWithWorkflowRemoved(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Remove Of Workflow'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateWorkflow \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckWorkflowExists \
                       CheckWorkflowChainExists \
                       CreateSecondBusinessTemplate \
                       UseSecondBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckWorkflowRemoved \
                       CheckWorkflowChainRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)


Aurel's avatar
Aurel committed
2662
  # test of module
Jérome Perrin's avatar
Jérome Perrin committed
2663
  def test_05_BusinessTemplateWithModule(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675
    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 \
Aurel's avatar
Aurel committed
2676
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698
                       AddModuleToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveModule \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2699
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2700 2701 2702
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
Aurel's avatar
Aurel committed
2703
                       CheckModulePermissions \
Aurel's avatar
Aurel committed
2704 2705 2706 2707 2708 2709 2710 2711
                       CheckModuleObjectsRemoved \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckModuleRemoved \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2712
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
2713 2714

  # test of categories
Jérome Perrin's avatar
Jérome Perrin committed
2715
  def test_06_BusinessTemplateWithBaseCategory(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738
    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 \
2739 2740
                       Tic \
                       CheckBaseCategoryRemoved \
Aurel's avatar
Aurel committed
2741 2742 2743 2744 2745 2746 2747 2748
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2749
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2750 2751
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764
                       SaveBaseCategoryUid \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckBaseCategoryExists \
                       CheckBaseCategoryUid \
Aurel's avatar
Aurel committed
2765 2766 2767 2768 2769
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
2770
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2771
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
2772

Aurel's avatar
Aurel committed
2773
  # test of actions
Jérome Perrin's avatar
Jérome Perrin committed
2774
  def test_07_BusinessTemplateWithOneAction(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
2775 2776
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2777
      message = 'Test Business Template With One Action'
Aurel's avatar
Aurel committed
2778 2779 2780 2781 2782
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
2783
                       CreateFirstAction \
Aurel's avatar
Aurel committed
2784 2785 2786 2787 2788
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
2789
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2808
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2809 2810
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
Aurel's avatar
Aurel committed
2811
                       CheckFirstActionExists \
Aurel's avatar
Aurel committed
2812 2813 2814 2815 2816 2817
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2818
    sequence_list.play(self, quiet=quiet)
2819

2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867

  def test_07_BusinessTemplateWithEmptyAction(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template Upgrade With Empty Action'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       CreateEmptyAction \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckFirstActionExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)



Jérome Perrin's avatar
Jérome Perrin committed
2868
  def test_08_BusinessTemplateWithTwoActions(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
2869 2870
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2871
      message = 'Test Business Template With Two Actions'
Aurel's avatar
Aurel committed
2872 2873 2874 2875 2876
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
2877 2878
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
2879 2880 2881 2882
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
Aurel's avatar
Aurel committed
2883
                       AddSecondActionToBusinessTemplate \
Aurel's avatar
Aurel committed
2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       CreatePortalType \
Aurel's avatar
Aurel committed
2895
                       CreateFirstAction \
Aurel's avatar
Aurel committed
2896 2897 2898 2899 2900 2901 2902 2903
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2904
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2905
                       CheckSkinsLayers \
Aurel's avatar
Aurel committed
2906 2907
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
2908
                       CheckActionsOrder \
Aurel's avatar
Aurel committed
2909 2910 2911
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
Aurel's avatar
Aurel committed
2912
                       CheckSecondActionNotExists \
Aurel's avatar
Aurel committed
2913 2914 2915
                       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2916
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
2917

Jérome Perrin's avatar
Jérome Perrin committed
2918
  def test_09_BusinessTemplateWithPath(self, quiet=quiet, run=run_all_test):
2919 2920
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
2921
      message = 'Test Business Template With A Simple Path'
2922 2923 2924
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
2925
    # a simple path
2926
    sequence_string = '\
Aurel's avatar
Aurel committed
2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddBaseCategoryAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
2951
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
2952 2953 2954 2955 2956 2957 2958
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
Romain Courteaud's avatar
Romain Courteaud committed
2959
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
2960
    sequence_list.play(self, quiet=quiet)
2961

2962
  def test_091_BusinessTemplateDoNotUnindexObject(self, quiet=quiet, run=run_all_test):
2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991
    if not run: return
    if not quiet:
      message = 'Test Business Template Do Not Unindex Object At Build'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    # a simple path
    sequence_string = '\
                       CreateBaseCategory \
                       CreateCategories \
                       CreateNewBusinessTemplate \
                       Tic \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddBaseCategoryAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckUnindexActivityPresence \
                       Tic \
                       CheckPathNotUnindexAfterBuild \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       RemoveBaseCategory \
                       '

    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

Jérome Perrin's avatar
Jérome Perrin committed
2992
  def test_10_BusinessTemplateWithPathAndJoker1(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
2993 2994 2995 2996 2997
    if not run: return
    if not quiet:
      message = 'Test Business Template With Path And Joker *'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
Aurel's avatar
Aurel committed
2998
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025
    # 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 \
3026
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3027 3028 3029 3030 3031 3032 3033
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
Aurel's avatar
Aurel committed
3034
                       '
Aurel's avatar
Aurel committed
3035
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3036
    sequence_list.play(self, quiet=quiet)
3037

3038
  def test_101_BusinessTemplateUninstallWithPathAndJoker1Removed(self, quiet=quiet, run=run_all_test):
3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084
    if not run: return
    if not quiet:
      message = 'Test Business Template Uninstall With Path And Joker * Removed'
      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 \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       RemoveCategories \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

Jérome Perrin's avatar
Jérome Perrin committed
3085
  def test_11_BusinessTemplateWithPathAndJoker2(self, quiet=quiet, run=run_all_test):
3086 3087
    if not run: return
    if not quiet:
Aurel's avatar
Aurel committed
3088
      message = 'Test Business Template With Path And Joker **'
3089 3090 3091
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
3092
    # path with subobject recursively
3093
    sequence_string = '\
Aurel's avatar
Aurel committed
3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119
                       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 \
3120
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3121 3122 3123 3124 3125 3126 3127 3128 3129
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
                       '
3130
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3131
    sequence_list.play(self, quiet=quiet)
3132

3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185
  def test_111_BusinessTemplateWithContentTypeRegistry(self, quiet=quiet, run=run_all_test):
    """
      Test if content_type_registry is propertly exported and installed within
      business template (as path).
      This test shows that there is a slight issue - when the bt that brought
      content_type_registry is uninstalled, the registry is removed altogether,
      not restored, which maybe is an issue and maybe not.
      The sequence string does not do CheckNoTrashBin after installing
      template because there is the old registry (I think) and it is ok.
    """
    if not run: return
    if not quiet:
      message = 'Test Business Template With Content Type Registry As Path'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    # a simple path
    sequence_string = '\
                       AddEntryToContentTypeRegistry \
                       CheckContentTypeRegistryHasNewEntry \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddContentTypeRegistryAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveContentTypeRegistryNewEntry \
                       CheckContentTypeRegistryHasNoNewEntry \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckContentTypeRegistryHasNewEntry \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

Aurel's avatar
Aurel committed
3186
  def test_12_BusinessTemplateWithCatalogMethod(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220
    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 \
3221
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3222 3223 3224 3225 3226 3227 3228 3229 3230 3231
                       CheckSkinsLayers \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckKeysAndTableRemoved \
                       CheckCatalogMethodRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3232
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3233

Jérome Perrin's avatar
Jérome Perrin committed
3234
  def test_13_BusinessTemplateWithRole(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265
    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 \
3266
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3267 3268 3269 3270 3271 3272 3273 3274
                       CheckSkinsLayers \
                       CheckRoleExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckRoleRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3275
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3276

Jérome Perrin's avatar
Jérome Perrin committed
3277
  def test_14_BusinessTemplateWithLocalRoles(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310
    if not run: return
    if not quiet:
      message = 'Test Business Template With Local Roles'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateLocalRoles \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddLocalRolesToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveLocalRoles \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3311
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3312 3313 3314 3315 3316 3317 3318 3319 3320 3321
                       CheckSkinsLayers \
                       CheckLocalRolesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckLocalRolesRemoved \
                       RemoveModule \
                       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3322
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3323

Jérome Perrin's avatar
Jérome Perrin committed
3324
  def test_15_BusinessTemplateWithPropertySheet(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355
    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 \
3356
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3357 3358 3359 3360 3361 3362 3363 3364
                       CheckSkinsLayers \
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPropertySheetRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3365
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3366 3367


3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399
  def test_155_BusinessTemplateUpdateWithPropertySheet(self, quiet=quiet, 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 \
3400
                       CheckNoTrashBin \
3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430
                       CheckSkinsLayers \
                       CheckPropertySheetExists \
                       RemovePropertySheet \
                       CreateUpdatedPropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CreatePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckUpdatedPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPropertySheetRemoved \
Christophe Dumez's avatar
Christophe Dumez committed
3431
                       CheckWorkflowChainRemoved \
3432 3433 3434 3435
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

Aurel's avatar
Aurel committed
3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546
  def test_156_BusinessTemplateWithConstraint(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Constraint'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateConstraint \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddConstraintToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveConstraint \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckConstraintExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckConstraintRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

  def test_157_BusinessTemplateUpdateWithConstraint(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Constraint'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateConstraint \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddConstraintToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveConstraint \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckConstraintExists \
                       RemoveConstraint \
                       CreateUpdatedConstraint \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddConstraintToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CreateConstraint \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckUpdatedConstraintExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckConstraintRemoved \
                       CheckWorkflowChainRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

Jérome Perrin's avatar
Jérome Perrin committed
3547
  def test_16_BusinessTemplateWithAllItems(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561
    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
3562 3563
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
3564 3565 3566
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
3567
                       CreateLocalRoles \
Aurel's avatar
Aurel committed
3568 3569 3570 3571
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3572
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
3573 3574 3575 3576 3577
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
3578
                       AddWorkflowChainToBusinessTemplate \
Aurel's avatar
Aurel committed
3579 3580 3581
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
3582
                       AddLocalRolesToBusinessTemplate \
Aurel's avatar
Aurel committed
3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611
                       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 \
3612
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3613 3614 3615 3616 3617 3618 3619 3620
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
3621 3622
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
3623 3624 3625
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
3626
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       CheckModuleRemoved \
                       CheckSkinFolderRemoved \
                       CheckBaseCategoryRemoved \
                       CheckWorkflowRemoved \
                       CheckCatalogMethodRemoved \
                       CheckKeysAndTableRemoved \
                       CheckRoleRemoved \
                       CheckPropertySheetRemoved \
                       CheckSkinsLayers \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3643
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3644 3645 3646



Jérome Perrin's avatar
Jérome Perrin committed
3647
  def test_17_SubobjectsAfterUpgradOfBusinessTemplate(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661
    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 \
Aurel's avatar
Aurel committed
3662
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675
                       AddModuleToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
                       RemoveBaseCategory \
3676
                       RemovePortalType \
Aurel's avatar
Aurel committed
3677 3678 3679 3680 3681 3682 3683 3684 3685 3686
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3687
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720
                       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 \
Aurel's avatar
Aurel committed
3721
                       '
Aurel's avatar
Aurel committed
3722
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3723
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3724

Jérome Perrin's avatar
Jérome Perrin committed
3725
  def test_18_upgradeBusinessTemplateWithAllItems(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740
    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
3741 3742
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
3743 3744 3745
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
3746
                       CreateLocalRoles \
Aurel's avatar
Aurel committed
3747 3748 3749 3750
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3751
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
3752 3753 3754 3755 3756
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
3757
                       AddWorkflowChainToBusinessTemplate \
Aurel's avatar
Aurel committed
3758 3759 3760
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
3761
                       AddLocalRolesToBusinessTemplate \
Aurel's avatar
Aurel committed
3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790
                       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 \
3791
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3792 3793 3794 3795 3796 3797 3798 3799
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
3800 3801
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
3802 3803 3804
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
3805
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816
                       CheckPropertySheetExists \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
3817
                       CheckWorkflowBackup \
Aurel's avatar
Aurel committed
3818 3819 3820 3821 3822 3823 3824
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
3825
                       CheckWorkflowChainExists \
Aurel's avatar
Aurel committed
3826 3827
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
3828 3829 3830
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
3831
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
3832 3833
                       CheckPropertySheetExists \
                       CheckSkinsLayers \
3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
Aurel's avatar
Aurel committed
3845 3846
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3847
    sequence_list.play(self, quiet=quiet)
3848

Aurel's avatar
Aurel committed
3849
  # test specific to erp5_core
Jérome Perrin's avatar
Jérome Perrin committed
3850
  def test_19_checkUpdateBusinessTemplateWorkflow(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3851 3852 3853 3854 3855 3856 3857
    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 = '\
3858 3859 3860 3861 3862 3863 3864
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
3865 3866
                       CreateFirstAction \
                       CreateSecondAction \
3867 3868 3869
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
3870
                       CreateLocalRoles \
3871
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
3872 3873
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
3874
                       ClearBusinessTemplateField \
Aurel's avatar
Aurel committed
3875
                       SetUpdateWorkflowFlagInBusinessTemplate \
3876
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3877
                       FillPortalTypesFields \
3878 3879 3880 3881 3882
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
3883
                       AddWorkflowChainToBusinessTemplate \
3884 3885 3886
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
3887
                       AddLocalRolesToBusinessTemplate \
3888
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
3909 3910 3911 3912 3913 3914 3915
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
3916 3917
                       CheckFirstActionExists \
                       CheckSecondActionExists \
3918 3919 3920
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
3921
                       CheckLocalRolesExists \
3922 3923 3924 3925 3926 3927 3928 3929 3930 3931
                       CheckPropertySheetExists \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
Aurel's avatar
Aurel committed
3932 3933
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
3934
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
3935 3936


Jérome Perrin's avatar
Jérome Perrin committed
3937
  def test_20_checkUpdateTool(self, quiet=quiet, run=run_all_test):
Aurel's avatar
Aurel committed
3938 3939 3940 3941 3942 3943 3944
    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 = '\
3945 3946 3947 3948 3949 3950 3951
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
3952 3953
                       CreateFirstAction \
                       CreateSecondAction \
3954 3955 3956
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
3957
                       CreateLocalRoles \
3958
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
3959 3960
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
3961
                       ClearBusinessTemplateField \
Aurel's avatar
Aurel committed
3962
                       SetUpdateToolFlagInBusinessTemplate \
3963
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3964
                       FillPortalTypesFields \
3965 3966 3967 3968 3969
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
3970
                       AddWorkflowChainToBusinessTemplate \
3971 3972 3973
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
3974
                       AddLocalRolesToBusinessTemplate \
3975
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
3976 3977 3978 3979 3980 3981 3982 3983 3984
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
3985 3986 3987 3988 3989 3990 3991 3992 3993 3994
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
Aurel's avatar
Aurel committed
3995
                       RemoveAllTrashBins \
3996
                       RemoveSimulationTool \
Aurel's avatar
Aurel committed
3997 3998 3999 4000 4001 4002 4003 4004
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4005
                       CheckSimulationToolExists \
Aurel's avatar
Aurel committed
4006
                       CheckSkinsLayers \
4007 4008 4009 4010 4011 4012 4013
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
4014 4015
                       CheckFirstActionExists \
                       CheckSecondActionExists \
4016 4017 4018
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
4019
                       CheckLocalRolesExists \
4020 4021 4022 4023 4024 4025 4026 4027 4028 4029
                       CheckPropertySheetExists \
                       RemovePortalType \
                       RemoveModule \
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
Aurel's avatar
Aurel committed
4030 4031
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4032
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
4033 4034


Jérome Perrin's avatar
Jérome Perrin committed
4035
  def test_21_CategoryIncludeSubobjects(self, quiet=quiet, run=run_all_test):
4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054
    if not run: return
    if not quiet:
      message = 'Test Category includes subobjects'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSubobjectsNotIncluded \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4055
    sequence_list.play(self, quiet=quiet)
4056

4057
  # test of portal types
Jérome Perrin's avatar
Jérome Perrin committed
4058
  def test_22_RevisionNumberIsIncremented(self, quiet=quiet, run=run_all_test):
4059 4060
    if not run: return
    if not quiet:
4061
      message = 'Test is revision number is incremented with the bt is built'
4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateNewBusinessTemplate \
		       UseExportBusinessTemplate \
		       CheckInitialRevision \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
		       stepCheckFirstRevision \
		       BuildBusinessTemplate \
		       stepCheckSecondRevision \
                       RemoveBusinessTemplate \
		       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4079
    sequence_list.play(self, quiet=quiet)
Aurel's avatar
Aurel committed
4080

Jérome Perrin's avatar
Jérome Perrin committed
4081
  def test_23_CheckNoDependencies(self, quiet=quiet, run=run_all_test):
4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096
    if not run: return
    if not quiet:
      message = 'Test if a new Business Template has no dependencies'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateNewBusinessTemplate \
		       UseExportBusinessTemplate \
                       CheckNoMissingDependencies \
                       RemoveBusinessTemplate \
		       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4097
    sequence_list.play(self, quiet=quiet)
4098

Jérome Perrin's avatar
Jérome Perrin committed
4099
  def test_24_CheckMissingDependency(self, quiet=quiet, run=run_all_test):
4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115
    if not run: return
    if not quiet:
      message = 'Test if a exception is raised when a dependency is missing'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateNewBusinessTemplate \
		       UseExportBusinessTemplate \
                       AddDependency \
                       CheckMissingDependencies \
                       RemoveBusinessTemplate \
		       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4116
    sequence_list.play(self, quiet=quiet)
4117

Jérome Perrin's avatar
Jérome Perrin committed
4118
  def test_25_CheckNoMissingDependency(self, quiet=quiet, run=run_all_test):
4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134
    if not run: return
    if not quiet:
      message = 'Test if the dependency problem is fixed when the dependency is installed'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateNewBusinessTemplate \
		       UseExportBusinessTemplate \
                       AddDependency \
                       CheckMissingDependencies \
                       CreateDependencyBusinessTemplate \
                       CheckMissingDependencies \
                       UseDependencyBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4135 4136 4137 4138 4139 4140
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
4141 4142 4143
                       CheckInstalledInstallationState \
                       UseExportBusinessTemplate \
                       CheckNoMissingDependencies \
Christophe Dumez's avatar
Christophe Dumez committed
4144
                       UseImportBusinessTemplate \
4145 4146 4147
                       UninstallBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckMissingDependencies \
Christophe Dumez's avatar
Christophe Dumez committed
4148
                       UseImportBusinessTemplate \
4149 4150
                       RemoveBusinessTemplate \
                       UseExportBusinessTemplate \
4151 4152 4153
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
Jérome Perrin's avatar
Jérome Perrin committed
4154
    sequence_list.play(self, quiet=quiet)
4155

4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189
  # test of skins
  def test_26_ImportWithDoubleSlashes(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Importing Business Template With Double Slashes'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveSkinFolder \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       AddExtraSlashesToTemplatePath \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4190
                       CheckNoTrashBin \
4191 4192 4193 4194 4195 4196 4197 4198 4199 4200
                       CheckSkinsLayers \
                       CheckSkinFolderExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSkinFolderRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4201
  def test_27_CheckInstallWithBackup(self, quiet=quiet, run=run_all_test):
4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218
    if not run: return
    if not quiet:
      message = 'Test if backup works during installation of a bt with subfolder in skin folder'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateSkinFolder \
                       CheckSkinFolderExists \
                       CreateSkinSubFolder \
                       CheckSkinSubFolderExists \
                       CreateNewObjectInSkinSubFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4219 4220 4221 4222 4223 4224
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
4225 4226 4227 4228
                       UninstallBusinessTemplate \
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
4229
    sequence_list.play(self, quiet=quiet)
4230

4231
  def test_28_CheckBuildWithUnexistingPath(self, quiet=quiet, run=run_all_test):
4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244
    if not run: return
    if not quiet:
      message = 'Test if build fails when one of the paths does not exist'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
    		       CreatePortalType \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPathToBusinessTemplate \
                       BuildBusinessTemplateFail \
                       RemoveBusinessTemplate \
4245
                       RemovePortalType \
4246 4247
                       '
    sequence_list.addSequenceString(sequence_string)
4248
    sequence_list.play(self, quiet=quiet)
4249

4250 4251 4252 4253 4254 4255 4256 4257
  def test_29_CheckUninstallRemovedSkinFolder(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test if uninstall works even when the skin folder has already been removed from the site'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
4258
                       CreatePortalType \
4259 4260 4261 4262 4263 4264
                       CreateSkinFolder \
                       CheckSkinFolderExists \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4265 4266
                       SaveBusinessTemplate \
                       RemoveBusinessTemplate \
4267
                       RemovePortalType \
Christophe Dumez's avatar
Christophe Dumez committed
4268 4269 4270
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
4271 4272 4273 4274 4275 4276 4277
                       RemoveSkinFolder \
                       UninstallBusinessTemplate \
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302
  def test_30_CheckInstalledCatalogProperties(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test if installing some new catalog properties overwrites '\
                'existing ones'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       ModifyCatalogConfiguration \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckCatalogConfigurationKept \
                       UninstallBusinessTemplate \
                       CheckCatalogConfigurationKept \
4303
                       RemoveCatalogLocalConfiguration \
4304 4305 4306
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345

  def test_31_BusinessTemplateWithCatalogMethod(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test that we keep local changes if we specify a list of objects to update'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CreateNewCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddNewCatalogMethodToBusinessTemplate \
                       CheckCatalogMethodExists \
                       AddKeysAndTableToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       ChangePreviousCatalogMethod \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       PartialCatalogMethodInstall \
                       CheckCatalogMethodChangeKept \
4346
                       RemoveKeysAndTable \
4347 4348 4349 4350
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4351
  def test_32_BusinessTemplateWithDuplicatedPortalTypes(self, quiet=quiet,
4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362
                                                        run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With Duplicated Portal Types'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateSecondAction \
4363
                       CreateWorkflow \
4364 4365 4366
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
4367 4368
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
4369 4370 4371 4372 4373
                       AddSecondActionToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemovePortalType \
4374
                       RemoveWorkflow \
4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CreateDuplicatedBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDuplicatedPortalTypeToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallDuplicatedBusinessTemplate \
                       Tic \
                       \
                       CheckPortalTypeExists \
                       CheckSecondActionExists \
                       \
                       UninstallBusinessTemplate \
                       CheckDuplicatedPortalTypeRemoved \
                       UninstallPreviousBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450
    
  def stepSetSkinFolderRegistredSelections(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    skin_folder._setProperty(
          'business_template_registered_skin_selections', ('Foo',),
          type='tokens')
    
  def stepCheckSkinSelectionAdded(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_paths = ps.getSkinPaths()
    # a new skin selection is added
    self.assertTrue('Foo' in ps.getSkinSelections())
    # and it contains good layers
    layers = ps.getSkinPath('Foo').split(',')
    self.assertTrue(skin_id in layers, layers)
    self.assertTrue('erp5_core' in layers, layers)
    self.assertFalse('erp5_xhtml_style' in layers, layers)


  def test_33_BusinessTemplateWithNewSkinSelection(self, quiet=quiet,
                                                        run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Business Template With New Skin Selection'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       SetSkinFolderRegistredSelections \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CheckSkinSelectionAdded \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
    
4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491
  def test_34_UpgradeForm(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Upgrade Form'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       CreateNewForm \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveForm \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormGroups \
                       AddFormField \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveFormField \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormGroups \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
    
4492 4493 4494 4495
  def test_getInstalledBusinessTemplate(self):
    self.assertNotEquals(None, self.getPortal()\
        .portal_templates.getInstalledBusinessTemplate('erp5_core'))

4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516
  def test_CompareVersions(self):
    """Tests compare version on template tool. """
    compareVersions = self.getPortal().portal_templates.compareVersions
    self.assertEquals(0, compareVersions('1', '1'))
    self.assertEquals(0, compareVersions('1.2', '1.2'))
    self.assertEquals(0, compareVersions('1.2rc3', '1.2rc3'))
    self.assertEquals(0, compareVersions('1.0.0', '1.0'))

    self.assertEquals(-1, compareVersions('1.0', '1.0.1'))
    self.assertEquals(-1, compareVersions('1.0rc1', '1.0'))
    self.assertEquals(-1, compareVersions('1.0a', '1.0.1'))
    self.assertEquals(-1, compareVersions('1.1', '2.0'))


  def test_CompareVersionStrings(self):
    """Test compareVersionStrings on template tool"""
    compareVersionStrings = \
        self.getPortal().portal_templates.compareVersionStrings
    self.assertTrue(compareVersionStrings('1.1', '> 1.0'))
    self.assertFalse(compareVersionStrings('1.1rc1', '= 1.0'))
    self.assertFalse(compareVersionStrings('1.0rc1', '> 1.0'))
4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536
    self.assertFalse(compareVersionStrings('1.0rc1', '>= 1.0'))
    self.assertTrue(compareVersionStrings('1.0rc1', '>= 1.0rc1'))
  

  def test_checkDependencies(self):
    from Products.ERP5Type.Document.BusinessTemplate import \
          BusinessTemplateMissingDependency
    template_tool = self.getPortal().portal_templates
    erp5_core_version = template_tool.getInstalledBusinessTemplate(
                                    'erp5_core').getVersion()
    bt5 = self.getPortal().portal_templates.newContent(
          portal_type='Business Template',
          dependency_list=['erp5_core (>= %s)' % erp5_core_version])
    self.assertEquals(None, bt5.checkDependencies())
    
    bt5.setDependencyList(['erp5_core (> %s)' % erp5_core_version])
    self.assertRaises(BusinessTemplateMissingDependency, bt5.checkDependencies)
    
    bt5.setDependencyList(['not_exists (= 1.0)'])
    self.assertRaises(BusinessTemplateMissingDependency, bt5.checkDependencies)
4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553
   
  def test_download_http(self):
    test_web = self.portal.portal_templates.download(
        'http://www.erp5.org/dists/snapshot/test_bt5/test_web.bt5')
    self.assertEquals(test_web.getPortalType(), 'Business Template')
    self.assertEquals(test_web.getTitle(), 'test_web')
    self.assertTrue(test_web.getRevision())

  def test_download_svn(self):
    # if the page looks like a svn repository, template tool will use pysvn to
    # get the bt5.
    test_web = self.portal.portal_templates.download(
        'https://svn.erp5.org/repos/public/erp5/trunk/bt5/test_web')
    self.assertEquals(test_web.getPortalType(), 'Business Template')
    self.assertEquals(test_web.getTitle(), 'test_web')
    self.assertTrue(test_web.getRevision())

4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636
  def stepCreateCustomWorkflow(self, sequence=None, sequence_list=None, **kw):
    """
    Create a custom workflow
    """
    pw = self.getWorkflowTool()
    pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', 
                          'custom_geek_workflow')
    workflow = pw._getOb('custom_geek_workflow', None)
    self.failUnless(workflow is not None)
    sequence.edit(workflow_id=workflow.getId())
    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)
    key = 'chain_Geek Object'
    if props.has_key(key):
      props[key] = '%s,custom_geek_workflow' % props[key]
    else:
      props['chain_Geek Object'] = 'custom_geek_workflow'
    pw.manage_changeWorkflows('', props=props)

  def stepCreateCustomBusinessTemplate(self, sequence=None, 
                                       sequence_list=None, **kw):
    """
    Create a custom Business Template
    """
    pt = self.getTemplateTool()
    template = pt.newContent(portal_type='Business Template')
    self.failUnless(template.getBuildingState() == 'draft')
    self.failUnless(template.getInstallationState() == 'not_installed')
    template.edit(title='custom geek template',
                  version='1.0',
                  description='custom bt for unit_test')
    sequence.edit(export_bt=template)

  def stepCheckCustomWorkflowChain(self, sequence=None, sequence_list=None, **kw):
    """
    Check custom workflow chain
    """
    present = 0
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    if cbt is not None:
      for id, wf_ids in cbt.items():
        if id == "Geek Object":
          present = 1
    self.assertEqual(present, 1)
    self.assertSameSet(cbt['Geek Object'],
                       ('geek_workflow', 'custom_geek_workflow'))

  def stepCheckOriginalWorkflowChain(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
    Check original workflow chain
    """
    present = 0
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    if cbt is not None:
      for id, wf_ids in cbt.items():
        if id == "Geek Object":
          present = 1
    self.assertEqual(present, 1)
    self.assertSameSet(cbt['Geek Object'],
                       ('geek_workflow', ))

  def stepCheckEmptyWorkflowChain(self, sequence=None, 
                                  sequence_list=None, **kw):
    """
    Check that workflow chain is empty
    """
    present = 0
    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type
    if cbt is not None:
      for id, wf_ids in cbt.items():
        if id == "Geek Object":
          present = 1
          break
    if present:
      self.assertEqual(0, len(wf_ids))

4637
  def test_34_RemovePartialWorkflowChain(self, quiet=quiet, run=run_all_test):
4638 4639
    if not run: return
    if not quiet:
4640
      message = 'Test Remove Chain'
4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateWorkflow \
                       CheckOriginalWorkflowChain \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       CheckEmptyWorkflowChain \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       CheckOriginalWorkflowChain \
                       Tic \
                       \
                       CreateCustomWorkflow \
                       CheckCustomWorkflowChain \
                       CreateCustomBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveWorkflow \
                       CheckOriginalWorkflowChain \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CheckCustomWorkflowChain \
                       \
                       UninstallBusinessTemplate \
                       Tic \
                       CheckOriginalWorkflowChain \
                       CheckWorkflowChainExists \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
4699

4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740
  def stepCopyBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
    Copy business template
    """
    portal = self.getPortalObject()
    template_tool = portal.portal_templates
    import_bt = sequence.get('current_bt')
    cb_data = template_tool.manage_copyObjects([import_bt.getId()])
    copied, = template_tool.manage_pasteObjects(cb_data)
    sequence.edit(current_bt=template_tool._getOb(copied['new_id']))

  def stepRemoveWorkflowFromBusinessTemplate(self, sequence=None, 
                                             sequence_list=None, **kw):
    """
    Remove workflow to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    current_twi = list(bt.getTemplateWorkflowIdList())
    current_twi.remove(sequence.get('workflow_id', ''))
    bt.edit(template_workflow_id_list=current_twi)

  def stepRemoveWorkflowChainFromBusinessTemplate(self, sequence=None, 
                                                  sequence_list=None, **kw):
    """
    Remove workflow chain to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    workflow_id = sequence.get('workflow_id', '')
    new_value = []
    workflow_chain_list = list(bt.getTemplatePortalTypeWorkflowChainList())
    for workflow_chain in workflow_chain_list:
      portal_type, wkflow_id = workflow_chain.split(' | ')
      if wkflow_id != workflow_id:
        new_value.append(workflow_chain)
    bt.edit(template_portal_type_workflow_chain_list=new_value)

  def test_35_UpdatePartialWorkflowChain(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
4741
      message = 'Test Update Workflow Chain'
4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateWorkflow \
                       CheckOriginalWorkflowChain \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       CheckEmptyWorkflowChain \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       CheckOriginalWorkflowChain \
                       Tic \
                       \
                       CreateCustomWorkflow \
                       CheckCustomWorkflowChain \
                       CreateCustomBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveWorkflow \
                       CheckOriginalWorkflowChain \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CheckCustomWorkflowChain \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       RemoveWorkflowFromBusinessTemplate \
                       RemoveWorkflowChainFromBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       SaveBusinessTemplate \
                       ImportBusinessTemplate \
                       Tic \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckOriginalWorkflowChain \
                       CheckWorkflowChainExists \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891
  def stepCreatePortalTypeRole(self, sequence=None, sequence_list=None, **kw):
    """
    Create portal type role
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    role = RoleInformation('geek_role_definition', 
                           title='Geek Role Definition')
    setattr(pt, '_roles', [role])
    sequence.edit(portal_type_role='geek_role_definition')

  def stepAddPortalTypeRolesToBusinessTemplate(self, sequence=None, 
                                              sequence_list=None, **kw):
    """
    Add type role 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', ''))
    self.assertEqual(len(ptype_ids), 2)
    bt.edit(template_portal_type_roles_list=ptype_ids)

  def stepCheckPortalTypeRoleExists(self, sequence=None, 
                                    sequence_list=None, **kw):
    """
    Cehck that portal type role exist
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    role_list = pt._roles
    self.assertTrue('geek_role_definition' in \
                        [x.id for x in role_list])

  def test_36_CheckPortalTypeRoles(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Portal Type Roles'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreatePortalTypeRole \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddPortalTypeToBusinessTemplate \
                       AddPortalTypeRolesToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       RemovePortalType \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckPortalTypeExists \
                       CheckPortalTypeRoleExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907
  def stepModifyPortalType(self, sequence=None, sequence_list=None, **kw):
    """
    Modify Portal Type
    """
    pt = self.getTypeTool()
    object_type = pt._getOb('Geek Object', None)
    object_type.title = 'Modified %s' % object_type.title

  def stepUnmodifyPortalType(self, sequence=None, sequence_list=None, **kw):
    """
    Unmodify Portal Type
    """
    pt = self.getTypeTool()
    object_type = pt._getOb('Geek Object', None)
    object_type.title = object_type.title[len('Modified '):]

4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920
  def stepCheckModifiedPortalTypeExists(self, sequence=None, 
                                        sequence_list=None, **kw):
    """
    Check presence of modified portal type
    """
    self.stepCheckPortalTypeExists(sequence=sequence, 
                                   sequence_list=sequence_list, **kw)
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_type = pt._getOb(object_id, None)
    self.failUnless(object_type.title.startswith('Modified '))

  def test_37_UpdatePortalType(self, quiet=quiet, run=run_all_test):
4921 4922 4923 4924 4925 4926
    if not run: return
    if not quiet:
      message = 'Test Update Portal Type'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
4927

4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947
    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckFirstActionExists \
                       \
                       CreateSecondAction \
                       CheckSecondActionExists \
4948 4949
                       CreatePortalTypeRole \
                       CheckPortalTypeRoleExists \
4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967
                       \
                       ModifyPortalType \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       EditBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       SaveBusinessTemplate \
                       \
                       UnmodifyPortalType \
                       \
                       ImportBusinessTemplate \
                       Tic \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
4968
                       CheckModifiedPortalTypeExists \
4969 4970
                       CheckFirstActionExists \
                       CheckSecondActionExists \
4971
                       CheckPortalTypeRoleExists \
4972 4973 4974 4975
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)

4976 4977 4978 4979
def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestBusinessTemplate))
  return suite