testBusinessTemplate.py 311 KB
Newer Older
1
# -*- coding: utf-8 -*-
2 3
##############################################################################
#
Aurel's avatar
Aurel committed
4 5
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
#          Aurelien Calonne <aurel@nexedi.com>
6 7
#
# WARNING: This program as such is intended to be used by professional
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
8
# programmers who take the whole responsibility of assessing all potential
9 10
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
11
# guarantees and support are strongly adviced to contract a Free Software
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# 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.
#
##############################################################################

30
import unittest
31
import logging
32

33
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
Aurel's avatar
Aurel committed
34
from Acquisition import aq_base
35
from OFS.SimpleItem import SimpleItem
36
from App.config import getConfiguration
Aurel's avatar
Aurel committed
37
from Products.ERP5Type.tests.Sequence import SequenceList
Aurel's avatar
Aurel committed
38
from urllib import pathname2url
39
from Products.ERP5Type.Globals import PersistentMapping
Aurel's avatar
Aurel committed
40
from Products.CMFCore.Expression import Expression
41
from Products.ERP5Type.tests.utils import LogInterceptor
42
from Products.ERP5Type.Workflow import addWorkflowByType
43
from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
44
from Products.ERP5Type.tests.testDynamicClassGeneration import TestDeveloperMixin
45
from Products.ERP5VCS.WorkingCopy import getVcsTool
46
import shutil
Aurel's avatar
Aurel committed
47
import os
48
import gc
Nicolas Delaby's avatar
Nicolas Delaby committed
49 50
import random
import string
51 52
import tempfile
import glob
53

54
WORKFLOW_TYPE = 'erp5_workflow'
55

56 57 58 59
from Products.MimetypesRegistry.common import MimeTypeException
from Products.PortalTransforms.Transform import Transform
Transform_tr_init = Transform._tr_init
Transform_manage_beforeDelete = Transform.manage_beforeDelete
60

61
class BusinessTemplateMixin(TestDeveloperMixin, ERP5TypeTestCase, LogInterceptor):
62
  def getBusinessTemplateList(self):
63 64 65
    return ('erp5_base',
            'erp5_csv_style',
            )
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
  ## Ignore errors from PortalTransforms (e.g. missing binaries)

  def _catch_log_errors(self):
    LogInterceptor._catch_log_errors(self)
    level = self.level
    def _tr_init(*args, **kw):
      self.level = logging.ERROR
      try:
        Transform_tr_init(*args, **kw)
      finally:
        self.level = level
    Transform._tr_init = _tr_init
    def manage_beforeDelete(self, *args, **kw):
      try:
        Transform_manage_beforeDelete(self, *args, **kw)
      except MimeTypeException:
        assert self.output == 'BROKEN'
    Transform.manage_beforeDelete = manage_beforeDelete

  def _ignore_log_errors(self):
    Transform._tr_init = Transform_tr_init
    Transform.manage_beforeDelete = Transform_manage_beforeDelete
    LogInterceptor._ignore_log_errors(self)

  ###

92 93 94
  def afterSetUp(self):
    self.login()
    portal = self.getPortal()
95
    # create the fake catalog table
96
    sql_connection = self.getSQLConnection()
97 98
    sql = 'create table if not exists `fake_catalog` (`toto` BIGINT)'
    sql_connection.manage_test(sql)
Aurel's avatar
Aurel committed
99
    self._catch_log_errors()
100

101
    # remove default predicate which matches anything
102 103 104
    content_type_registry = getattr(portal, 'content_type_registry', None)
    if (content_type_registry is not None and
        'any' in content_type_registry.predicate_ids):
105
      content_type_registry.removePredicate('any')
106
      self.commit()
107

Jérome Perrin's avatar
Jérome Perrin committed
108
  def beforeTearDown(self):
109
    """Remove objects created in tests."""
110
    pw = self.getWorkflowTool()
111

112 113 114 115
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
116 117 118
        wf_ids = list(wf_ids)
        if 'geek_workflow' in wf_ids:
          wf_ids.remove('geek_workflow')
119 120
        if id != "Geek Object":
          props['chain_%s' % id] = ', '.join(wf_ids)
121

122
    pw.manage_changeWorkflows('', props=props)
Jérome Perrin's avatar
Jérome Perrin committed
123 124
    if 'erp5_geek' in self.getSkinsTool().objectIds():
      self.getSkinsTool().manage_delObjects(['erp5_geek'])
125 126 127 128 129 130 131
      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)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
132
        ps.manage_skinLayers(skinpath=tuple(new_selection),
133
                             skinname=skin_name, add_skin=1)
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    if 'erp5_static' in self.getSkinsTool().objectIds():
      self.getSkinsTool().manage_delObjects(['erp5_static'])
      ps = self.getSkinsTool()
      for skin_name, selection in ps.getSkinPaths():
        new_selection = []
        selection = selection.split(',')
        for skin_id in selection:
          if skin_id != 'erp5_static':
            new_selection.append(skin_id)
        ps.manage_skinLayers(skinpath=tuple(new_selection),
                             skinname=skin_name, add_skin=1)

    if 'Foo' in self.getSkinsTool().getSkinSelections():
      self.getSkinsTool().manage_skinLayers(chosen=('Foo',), del_skin=1)

Jérome Perrin's avatar
Jérome Perrin committed
149 150 151 152 153 154
    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'])
155 156
    if 'custom_geek_workflow' in self.getWorkflowTool().objectIds():
      self.getWorkflowTool().manage_delObjects(['custom_geek_workflow'])
157 158 159
    for business_template in self.getTemplateTool().contentValues():
      if business_template.getTitle() == 'geek template':
        self.getTemplateTool().manage_delObjects([business_template.getId()])
160 161 162 163
    self.stepRemoveAllTrashBins()
    catalog = self.portal.portal_catalog.erp5_mysql_innodb
    for method_id in ('z_fake_method', 'z_another_fake_method'):
      if method_id in catalog.objectIds():
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
164
        catalog.manage_delObjects([method_id])
165 166 167 168 169 170 171
      sql_uncatalog_object = list(catalog.sql_uncatalog_object)
      if method_id in sql_uncatalog_object:
        sql_uncatalog_object.remove(method_id)
        sql_uncatalog_object.sort()
        catalog.sql_uncatalog_object = tuple(sql_uncatalog_object)
      if method_id in catalog.filter_dict:
        del catalog.filter_dict[method_id]
172 173 174 175 176 177 178 179
    for obj_id in ('another_file', 'test_document', 'dummy_type_provider'):
      if obj_id in self.portal.objectIds():
        self.portal.manage_delObjects([obj_id])
    types_tool = self.portal.portal_types
    registered_type_provider_list = list(types_tool.type_provider_list)
    if 'dummy_type_provider' in registered_type_provider_list:
      registered_type_provider_list.remove('dummy_type_provider')
      types_tool.type_provider_list = tuple(registered_type_provider_list)
180 181 182 183
    property_sheet_tool = self.getPortalObject().portal_property_sheets
    for property_sheet in ('UnitTest',):
      if property_sheet in property_sheet_tool.objectIds():
        property_sheet_tool.manage_delObjects([property_sheet])
184
    self.commit()
Jérome Perrin's avatar
Jérome Perrin committed
185
    self._ignore_log_errors()
186

187 188 189 190 191 192 193 194 195 196
  def getBusinessTemplate(self,title):
    """
      Get a business template at portal_templates
    """
    template_tool = self.getTemplateTool()
    for bt in template_tool.objectValues(filter={'portal_type':'Business Template'}):
      if bt.getTitle() == title:
        return bt
    return None

197
  def stepUseCoreBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
198 199 200
    """
    Define erp5_core as current bt
    """
201
    core_bt = self.getBusinessTemplate('erp5_core')
Aurel's avatar
Aurel committed
202 203 204
    self.failIf(core_bt is None)
    sequence.edit(current_bt=core_bt)

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
  def stepCreateTest(self, sequence=None, **kw):
    test_title = 'UnitTest'
    test_data = """class UnitTest:
  pass"""
    cfg = getConfiguration()
    file_path = os.path.join(cfg.instancehome, 'tests', test_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(test_data)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(test_title=test_title, test_path=file_path,
        test_data=test_data)

  def stepAddTestToBusinessTemplate(self, sequence=None, **kw):
    bt = sequence['current_bt']
    bt.edit(template_test_id_list=[sequence['test_title']])

  def stepRemoveTest(self, sequence=None, **kw):
    test_path = sequence['test_path']
    os.remove(test_path)
    self.failIf(os.path.exists(test_path))

  def stepCheckTestExists(self, sequence=None, **kw):
    self.failIf(not os.path.exists(sequence['test_path']))

  def stepCheckTestRemoved(self, sequence=None, **kw):
    self.failIf(os.path.exists(sequence['test_path']))

235
  def stepCopyCoreBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
236 237 238 239
    """
    Copy erp5_core as new Business Template
    """
    template_tool = self.getTemplateTool()
240
    core_bt = self.getBusinessTemplate('erp5_core')
Aurel's avatar
Aurel committed
241 242 243 244 245 246 247 248 249
    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)

250
  def stepUseCopyCoreBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
251 252 253 254 255 256
    """
    Define erp5_core as current bt
    """
    bt = sequence.get('copy_bt')
    sequence.edit(current_bt=bt, export_bt=bt)

257
  def stepBuildCopyCoreBusinessTemplate(self, sequence=None, **kw):
Yusuke Muraoka's avatar
Yusuke Muraoka committed
258 259 260 261 262 263 264
    """
    Build copied core bt
    """
    bt = sequence.get('copy_bt')
    self.assertEquals(bt.getTitle(), 'erp5_core')
    bt.build()

265
  def stepInstallCopyCoreBusinessTemplate(self, sequence=None, **kw):
Yusuke Muraoka's avatar
Yusuke Muraoka committed
266 267 268 269 270 271 272 273
    """
    Install copied core bt
    """
    bt = sequence.get('copy_bt')
    self.assertEquals(bt.getTitle(), 'erp5_core')
    self.assertEquals(bt.getInstallationState(), 'not_installed')
    bt.install()

274
  def stepCheckOriginalAndCopyBusinessTemplate(self, sequence=None, **kw):
Yusuke Muraoka's avatar
Yusuke Muraoka committed
275 276 277 278 279 280 281 282 283 284
    original_bt = sequence.get('current_bt')
    copy_bt = sequence.get('copy_bt')
    self.assertEquals(original_bt.getBuildingState(), 'built')
    self.assertEquals(copy_bt.getBuildingState(), 'built')

    for item_name in original_bt._item_name_list:
      original_obj = getattr(original_bt, item_name)
      copy_obj = getattr(copy_bt, item_name)
      self.failIf(original_obj is None)
      self.failIf(copy_obj is None)
285
      self.failIfDifferentSet(original_obj.getKeys(), copy_obj.getKeys())
Yusuke Muraoka's avatar
Yusuke Muraoka committed
286

287
  def stepUseExportBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
288 289 290 291 292
    """
    Define export_bt as current bt
    """
    bt = sequence.get('export_bt')
    sequence.edit(current_bt=bt)
293

294
  def stepUseSecondBusinessTemplate(self, sequence=None, **kw):
295 296 297 298 299 300
    """
    Define second_export_bt as current bt
    """
    bt = sequence.get('second_export_bt')
    sequence.edit(current_bt=bt)

301
  def stepUseDependencyBusinessTemplate(self, sequence=None, **kw):
302 303 304 305 306
    """
      Define dependency_bt as current bt
    """
    bt = sequence.get('dependency_bt')
    sequence.edit(current_bt=bt)
Aurel's avatar
Aurel committed
307

308
  def stepUseImportBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
309 310 311 312 313
    """
    Define import_bt as current bt
    """
    bt = sequence.get('import_bt')
    sequence.edit(current_bt=bt)
Aurel's avatar
Aurel committed
314

315
  def stepCheckPreinstallReturnSomething(self, sequence=None, **kw):
316 317 318 319 320 321 322
    """
    In case of upgrade preinstall call must return at least one element
    which is marked as new/updated/removed
    """
    bt = sequence.get('current_bt', None)
    self.assertNotEquals(len(bt.preinstall()), 0)

323
  def stepCheckCatalogPreinstallReturnCatalogMethod(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
324 325 326
    bt = sequence.get('current_bt', None)
    self.assertEquals(bt.preinstall(), {'portal_catalog/erp5_mysql_innodb/z_fake_method': ['Modified', 'CatalogMethod']})

327
  def stepCheckInstalledInstallationState(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
328 329 330 331 332 333
    """
    Check if installation state is installed
    """
    bt = sequence.get('current_bt', None)
    self.assertEquals(bt.getInstallationState(), 'installed')

334
  def stepCheckNotInstalledInstallationState(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
335 336 337 338 339 340
    """
    Check if installation state is not_installed
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getInstallationState(), 'not_installed')

341
  def stepCheckReplacedInstallationState(self, sequence=None, seqeunce_list=None, **kw):
Aurel's avatar
Aurel committed
342 343 344 345 346 347
    """
    Check if installation state is replaced
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getInstallationState(), 'replaced')

348
  def stepCheckModifiedBuildingState(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
349 350
    """
    Check if the building state is modified.
351
    """
Aurel's avatar
Aurel committed
352 353 354
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getBuildingState(), 'modified')

355
  def stepCheckBuiltBuildingState(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
356 357 358 359 360 361
    """
    Check if the building state is built.
    """
    bt = sequence.get('current_bt')
    self.assertEquals(bt.getBuildingState(), 'built')

362
  def stepCheckTools(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
363 364 365 366 367 368 369 370
    """
    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
371 372
    self.failUnless(self.getTrashTool() is not None)

373
  def stepCheckSkinsLayers(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
374 375 376 377 378 379 380 381
    """
    Check skins layers
    """
    skins_tool = self.getSkinsTool()
    for skin_name, selection in skins_tool.getSkinPaths():
      if skin_name == 'View':
        self.failIf('erp5_csv_style' in selection)
        self.failIf('erp5_core' not in selection)
382
        self.failIf('erp5_xhtml_style' not in selection)
Aurel's avatar
Aurel committed
383
      if skin_name == 'Print':
384
        self.failIf('erp5_xhtml_style' in selection)
Aurel's avatar
Aurel committed
385 386 387
        self.failIf('erp5_csv_style' in selection)
        self.failIf('erp5_core' not in selection)
      if skin_name == 'CSV':
388
        self.failIf('erp5_xhtml_style' in selection)
Aurel's avatar
Aurel committed
389 390 391
        self.failIf('erp5_core' not in selection)
        self.failIf('erp5_csv_style' not in selection)

392
  def stepCheckNoTrashBin(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
393 394 395 396 397 398
    """
    Check if there is no trash bins
    """
    trash = self.getTrashTool()
    self.assertEquals(len(trash.objectIds()), 0)

399
  def stepRemoveAllTrashBins(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
400 401 402 403 404 405 406 407 408
    """
    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)

409
  def stepCheckTrashBin(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
410 411 412 413 414 415 416 417 418 419
    """
    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
420
  def stepCreatePortalType(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
421 422
    """
    Create Portal Type
423 424
    """
    pt = self.getTypeTool()
Aurel's avatar
Aurel committed
425
    # create module object portal type
Julien Muchembled's avatar
Julien Muchembled committed
426
    object_type = pt.newContent('Geek Object', 'Base Type',
427
                                type_class='Person')
Aurel's avatar
Aurel committed
428 429 430
    self.failUnless(object_type is not None)
    sequence.edit(object_ptype_id=object_type.getId())
    # create module portal type
Julien Muchembled's avatar
Julien Muchembled committed
431
    module_type = pt.newContent('Geek Module', 'Base Type',
432
      type_class='Folder',
Julien Muchembled's avatar
Julien Muchembled committed
433 434 435 436 437
      type_filter_content_type=1,
      type_allowed_content_type_list=('Geek Object',),
      type_hidden_content_type_list=('Geek Object',),
      type_base_category_list=('destination',),
      type_property_sheet_list=('Version',))
438
    self.failUnless(module_type is not None)
439
    sequence.edit(module_ptype_id=module_type.getId(),
Julien Muchembled's avatar
Julien Muchembled committed
440 441 442 443 444
      module_ptype_filter_content_types=module_type.getTypeFilterContentType(),
      module_ptype_allowed_content_types=module_type.getTypeAllowedContentTypeList(),
      module_ptype_hidden_content_type_list=module_type.getTypeHiddenContentTypeList(),
      module_ptype_base_category_list=module_type.getTypeBaseCategoryList(),
      module_ptype_property_sheet_list=module_type.getTypePropertySheetList())
445

446
  def stepModifyPortalTypeInBusinessTemplate(self, sequence=None, **kw):
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
    """
    Modify Portal Type
    * remove Geek Object and add Geek Module in allowed_content_type
    * empty hidden_content_type
    * remove 'destination' and add 'source' in base_category_list
    * empty property_sheet_list
    """
    pt = self.getTypeTool()
    module_type = pt._getOb('Geek Module', None)
    self.failUnless(module_type is not None)
    module_type.allowed_content_types = list(module_type.allowed_content_types) + ['Geek Module']
    module_type.base_category_list = list(module_type.base_category_list) + ['source']
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_portal_type_allowed_content_type=('Geek Module | Geek Module',),
            template_portal_type_hidden_content_type=(),
            template_portal_type_base_category=('Geek Module | source',),
            template_portal_type_property_sheet=())
Julien Muchembled's avatar
Julien Muchembled committed
465 466 467 468
    sequence.edit(module_ptype_allowed_content_types=['Geek Module'],
                  module_ptype_hidden_content_type_list=[],
                  module_ptype_base_category_list=['source'],
                  module_ptype_property_sheet_list=[])
Aurel's avatar
Aurel committed
469

470
  def stepAddPortalTypeToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
471 472 473 474 475 476 477 478
    """
    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', ''))
479
    self.assertEqual(len(ptype_ids), 2)
Aurel's avatar
Aurel committed
480
    bt.edit(template_portal_type_id_list=ptype_ids)
481
    self.stepFillPortalTypesFields(sequence=sequence, **kw)
Aurel's avatar
Aurel committed
482

483
  def stepAddDuplicatedPortalTypeToBusinessTemplate(self, sequence=None, **kw):
484 485 486 487 488 489 490 491 492 493
    """
    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)

494
  def stepRemovePortalType(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
495
    """
Aurel's avatar
Aurel committed
496
    Remove PortalType
Aurel's avatar
Aurel committed
497 498 499 500 501 502 503 504 505 506
    """
    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)

507
  def stepRemoveFirstAction(self, sequence=None, **kw):
508 509
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
Julien Muchembled's avatar
Julien Muchembled committed
510 511 512 513 514
    action_id = sequence.get('first_action_id')
    object_type = pt[object_id]
    action_id, = [x.getId() for x in object_type.getActionInformationList()
                            if x.getReference() == action_id]
    object_type._delObject(action_id)
515

516
  def stepCheckPortalTypeExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
517 518 519 520 521 522 523 524
    """
    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)
Julien Muchembled's avatar
Julien Muchembled committed
525
    self.assertEqual(module_type.getTypeAllowedContentTypeList(),
526
        sequence.get('module_ptype_allowed_content_types'))
Julien Muchembled's avatar
Julien Muchembled committed
527
    self.assertEqual(module_type.getTypeHiddenContentTypeList(),
528
        sequence.get('module_ptype_hidden_content_type_list'))
Julien Muchembled's avatar
Julien Muchembled committed
529
    self.assertEqual(module_type.getTypeFilterContentType(),
530
        sequence.get('module_ptype_filter_content_types'))
Julien Muchembled's avatar
Julien Muchembled committed
531
    self.assertEqual(module_type.getTypeBaseCategoryList(),
532
        sequence.get('module_ptype_base_category_list'))
Julien Muchembled's avatar
Julien Muchembled committed
533
    self.assertEqual(module_type.getTypePropertySheetList(),
534
        sequence.get('module_ptype_property_sheet_list'))
Aurel's avatar
Aurel committed
535
    object_type = pt._getOb(object_id, None)
536
    self.failUnless(object_type is not None)
537

538
  def stepCheckPortalTypeRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
539 540 541 542 543 544 545 546 547 548
    """
    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)
549

550
  def stepCheckDuplicatedPortalTypeRemoved(self, sequence=None, **kw):
551 552 553 554 555 556 557 558
    """
    Check non presence of portal type
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_type = pt._getOb(object_id, None)
    self.failUnless(object_type is None)

559
  def stepFillPortalTypesFields(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
560 561 562 563 564 565 566
    """
    Fill portal types properties field in business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.getPortalTypesProperties()

567
  def stepFillWrongPortalTypesFields(self, sequence=None, **kw):
568 569 570 571 572 573 574 575 576
    """
    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)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
577

Aurel's avatar
Aurel committed
578
  # module
579
  def stepCreateModuleAndObjects(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
580 581 582 583 584 585 586 587
    """
    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
588
      id = "%s_%s" %('geek_module', n)
Aurel's avatar
Aurel committed
589 590
    module = portal.newContent(id=id, portal_type='Geek Module')
    self.failUnless(module is not None)
Aurel's avatar
Aurel committed
591 592
    # add a specific permission to module which do not use acquisition
    module.manage_permission('Copy or Move', ['Assignor'], False)
Aurel's avatar
Aurel committed
593 594 595 596 597 598 599 600
    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)

601
  def stepAddModuleToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
602 603 604 605 606 607 608 609
    """
    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])

610
  def stepCreateModuleObjects(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
611 612 613
    """
    Create objects into module
    """
Aurel's avatar
Aurel committed
614
    portal = self.getPortal()
Aurel's avatar
Aurel committed
615 616 617 618 619 620 621 622
    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
623
    sequence.edit(module_object_id_list=module_object_list)
Aurel's avatar
Aurel committed
624

625
  def stepRemoveModule(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
626 627 628 629 630 631 632 633
    """
    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)

634
  def stepCheckModuleExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
635 636 637 638 639 640 641 642
    """
    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)

643
  def stepCheckModulePermissions(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
    """
    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")

664
  def stepCheckModuleObjectsExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
665 666 667 668 669 670 671 672 673 674 675 676
    """
    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)

677
  def stepCheckModuleObjectsRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
678 679 680 681 682 683 684 685 686 687 688
    """
    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
689

690
  def stepCheckModuleRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
691 692 693 694 695
    """
    Check non presence of module
    """
    portal = self.getPortal()
    module_id = sequence.get("module_id")
Aurel's avatar
Aurel committed
696
    self.failIf(portal._getOb(module_id, None) is not None)
Aurel's avatar
Aurel committed
697 698

  # skins folder
699
  def stepCreateSkinFolder(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
700 701 702
    """
    Create a skin folder
    """
703
    ps = self.getSkinsTool()
Aurel's avatar
Aurel committed
704 705
    ps.manage_addProduct['OFSP'].manage_addFolder('erp5_geek')
    skin_folder = ps._getOb('erp5_geek', None)
706
    self.failUnless(skin_folder is not None)
Aurel's avatar
Aurel committed
707 708
    sequence.edit(skin_folder_id=skin_folder.getId())
    # add skin in layers
709 710
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
Aurel's avatar
Aurel committed
711 712
      if 'erp5_geek' not in selection:
        selection.append('erp5_geek')
713
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)
714

715
  def stepCreateAnotherSkinFolder(self, sequence=None, **kw):
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
    """
    Create another skin folder
    """
    ps = self.getSkinsTool()
    ps.manage_addProduct['OFSP'].manage_addFolder('erp5_nerd')
    skin_folder = ps._getOb('erp5_nerd', None)
    self.failUnless(skin_folder is not None)
    sequence.edit(another_skin_folder_id=skin_folder.getId())
    # add skin in layers
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
      if 'erp5_nerd' not in selection:
        selection.append('erp5_nerd')
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)

731
  def stepCreateStaticSkinFolder(self, sequence=None, **kw):
732 733 734 735 736 737 738 739 740 741 742 743 744
    """
    Create a skin folder not managed by the bt5
    """
    ps = self.getSkinsTool()
    ps.manage_addProduct['OFSP'].manage_addFolder('erp5_static')
    skin_folder = ps._getOb('erp5_static', None)
    self.failUnless(skin_folder is not None)
    sequence.edit(static_skin_folder_id=skin_folder.getId())
    # add skin in layers
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
      if 'erp5_static' not in selection:
        selection.append('erp5_static')
745
      ps.manage_skinLayers(skinpath=tuple(selection), skinname=skin_name,
746 747
                           add_skin=1)

748
  def stepCreateSkinSubFolder(self, sequence=None, **kw):
749 750 751 752 753 754 755
    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())
756

757
  def stepCheckSkinSubFolderExists(self, sequence=None, **kw):
758 759 760 761 762 763 764 765 766 767
    """
    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)
768

769
  def stepCreateNewForm(self, sequence=None):
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
    """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())
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
790
      group_dict[group] = id_list
791 792
    sequence.edit(form_id=form_id, group_dict=group_dict)

793
  def stepCreateNewFormIntoErp5Nerd(self, sequence=None):
794 795
    """Create a new ERP5 Form in a skin folder."""
    ps = self.getSkinsTool()
796
    skin_folder = ps._getOb('erp5_nerd', None)
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
    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
815
    sequence.edit(another_form_id=form_id)
816

817
  def stepRemoveForm(self, sequence=None):
818 819 820 821 822 823 824 825 826 827 828
    """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)

829
  def stepAddFormField(self, sequence=None):
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
    """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())
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
849
      group_dict[group] = id_list
850 851
    sequence.edit(group_dict=group_dict, field_id=field.getId())

852
  def stepModifyFormTitle(self, sequence=None):
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
    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)
    form_title = 'First Form Title'
    form.title = form_title
    self.assertNotEquals(form, None)
    self.assertEquals(sorted(form.get_groups(include_empty=1)),
                      sorted(['left', 'right', 'center', 'bottom', 'hidden']))
    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())
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
868
      group_dict[group] = id_list
869 870 871
    sequence.edit(group_dict=group_dict, field_id=field.getId(),
                  form_title=form_title)

872
  def stepRevertFormTitle(self, sequence=None):
873 874 875 876 877 878 879 880
    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)
    form_title = 'Second Form Title'
    form.title = form_title

881
  def stepCheckFormTitle(self, sequence=None):
882 883 884 885 886 887 888
    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.assertEquals('First Form Title', form.title)

889
  def stepCheckFormIsRemoved(self, sequence=None):
890 891 892 893 894 895 896 897
    """Check the form is exist in erp5_geek."""
    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.assertEquals(form, None)

898
  def stepCheckFormIsNotRemovedFromErp5Nerd(self, sequence=None):
899
    """Check the form is not exist in erp5_nerd."""
900
    ps = self.getSkinsTool()
901
    skin_folder = ps._getOb('erp5_nerd', None)
902 903 904 905 906
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)

907
  def stepRemoveFormField(self, sequence=None):
908 909 910 911 912 913 914 915 916 917 918 919 920
    """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)

921
  def stepCheckFormGroups(self, sequence=None):
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
    """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)

938
  def stepCheckFieldTitleIsNotRemovedFromErp5Nerd(self, sequence=None):
939 940 941 942 943 944 945
    """Check that field title is not removed form erp5_nerd."""
    ps = self.getSkinsTool()
    skin_folder = ps._getOb('erp5_nerd', None)
    self.assertNotEquals(skin_folder, None)
    form_id = sequence.get('form_id')
    form = skin_folder._getOb(form_id, None)
    self.assertNotEquals(form, None)
Tatuya Kamada's avatar
Tatuya Kamada committed
946 947
    title_field =form._getOb('my_title', None)
    self.assertNotEquals(title_field, None)
948

949
  def stepCreateNewObjectInSkinSubFolder(self, sequence=None, **kw):
950 951 952 953 954 955 956 957 958 959
    """
    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
960 961
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
962 963 964
    zsql_method = skin_subfolder._getOb(method_id, None)
    self.failUnless(zsql_method is not None)
    sequence.edit(zsql_method_id = method_id)
965

966
  def stepRemoveSkinFolder(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
967 968 969 970 971 972 973 974 975 976 977 978 979 980
    """
    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)

981
  def stepCheckSkinFolderExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
982 983 984 985 986 987
    """
    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
988
    self.failUnless(skin_folder is not None)
Aurel's avatar
Aurel committed
989

990
  def stepCheckSkinFolderRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
991 992 993 994 995 996 997 998
    """
    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)

999
  def stepAddSkinFolderToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1000
    """
1001
    Add skin folder to business template
Aurel's avatar
Aurel committed
1002 1003 1004
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
1005 1006 1007
    skin_id = sequence.get('skin_folder_id', '')
    self.failIfEqual(skin_id, '')
    bt.edit(template_skin_id_list=[skin_id])
1008

1009
  def stepAddAnotherSkinFolderToBusinessTemplate(self, sequence=None, **kw):
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    skin_id = sequence.get('another_skin_folder_id', '')
    self.failIfEqual(skin_id, '')
    current_skin_id_list = bt.getTemplateSkinIdList()
    template_skin_id_list = []
    template_skin_id_list.extend(current_skin_id_list)
    template_skin_id_list.append(skin_id)
    bt.edit(template_skin_id_list=template_skin_id_list)


Arnaud Fontaine's avatar
Arnaud Fontaine committed
1021
  def stepAddRegisteredSelectionToBusinessTemplate(self, sequence=None, **kw):
1022 1023 1024 1025 1026 1027 1028 1029
    """
    Add registered selection to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_registered_skin_selection_list = \
        ('%s | Foo' % sequence.get('skin_folder_id'), ))

Arnaud Fontaine's avatar
Arnaud Fontaine committed
1030
  def stepEditRegisteredSelectionToBusinessTemplate(self, sequence=None, **kw):
1031 1032 1033 1034 1035 1036 1037 1038 1039
    """
    Add registered selection to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_registered_skin_selection_list = \
        ('%s | Foo' % sequence.get('skin_folder_id'),
         '%s | Bar' % sequence.get('skin_folder_id'),))

1040
  def stepAddPathToBusinessTemplate(self, sequence=None, **kw):
1041 1042 1043 1044 1045 1046
    """
    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',])
1047

Aurel's avatar
Aurel committed
1048
  # Base Category
1049
  def stepCreateBaseCategory(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1050 1051 1052
    """
    Create Base category
    """
1053
    pc = self.getCategoryTool()
Aurel's avatar
Aurel committed
1054
    base_category = pc.newContent(portal_type = 'Base Category')
1055
    self.failUnless(base_category is not None)
1056
    sequence.edit(bc_id=base_category.getId(),)
1057
    sequence.edit(base_category_uid=base_category.getUid(),)
Aurel's avatar
Aurel committed
1058

1059
  # Content Type Registry
1060
  def stepAddEntryToContentTypeRegistry(self, sequence=None, **kw):
1061 1062 1063 1064 1065 1066 1067 1068
    """
    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')

1069
  def stepCheckContentTypeRegistryHasNewEntry(self, sequence=None, **kw):
1070 1071 1072 1073 1074 1075
    """
      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')

1076
  def stepAddContentTypeRegistryAsPathToBusinessTemplate(self, sequence=None, **kw):
1077 1078 1079 1080 1081 1082 1083
    """
      Add Content Type Registry to Business template
    """
    bt = sequence.get('current_bt')
    path = 'content_type_registry'
    bt.edit(template_path_list=[path])

1084
  def stepRemoveContentTypeRegistryNewEntry(self, sequence=None, **kw):
1085 1086 1087 1088 1089 1090
    """
      Remove new entry from content_type_registry
    """
    ctr = getattr(self.getPortal(), 'content_type_registry')
    ctr.removePredicate('test')

1091
  def stepCheckContentTypeRegistryHasNoNewEntry(self, sequence=None, **kw):
1092 1093 1094 1095 1096 1097
    """
      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)

1098
  def stepAddBaseCategoryToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1099 1100 1101 1102 1103
    """
    Add Base category to Business template
    """
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
1104
    bt.edit(template_base_category_list=[bc_id,])
Aurel's avatar
Aurel committed
1105

1106
  def stepAddBaseCategoryAsPathToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1107 1108 1109 1110 1111
    bc_id = sequence.get('bc_id')
    bt = sequence.get('current_bt')
    path = 'portal_categories/'+bc_id
    bt.edit(template_path_list=[path])

1112
  def stepRemoveBaseCategory(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1113 1114 1115 1116 1117 1118 1119
    """
    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
1120
    self.failUnless(base_category is None)
Aurel's avatar
Aurel committed
1121

1122
  def stepCheckBaseCategoryExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1123 1124 1125 1126 1127 1128
    """
    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
1129
    self.failUnless(base_category is not None)
Aurel's avatar
Aurel committed
1130

1131
  def stepCheckBaseCategoryRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1132 1133 1134 1135 1136 1137
    """
    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
1138
    self.failUnless(base_category is None)
Aurel's avatar
Aurel committed
1139

1140
  def stepSaveBaseCategoryUid(self, sequence=None, **kw):
1141 1142 1143 1144 1145 1146 1147 1148
    """
    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())

1149
  def stepCheckBaseCategoryUid(self, sequence=None, **kw):
1150 1151 1152 1153 1154 1155 1156 1157 1158
    """
    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
1159
  # categories
1160
  def stepCreateCategories(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1161 1162 1163 1164 1165
    """
    Create categories into a base category
    """
    bc_id = sequence.get('bc_id')
    pc = self.getCategoryTool()
Aurel's avatar
Aurel committed
1166
    base_category = pc._getOb(bc_id, None)
Aurel's avatar
Aurel committed
1167 1168 1169 1170 1171 1172 1173 1174
    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)

1175
  def stepAddCategoriesAsPathToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1176 1177 1178 1179 1180 1181 1182 1183
    """
    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])

1184
  def stepCheckCategoriesExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
    """
    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)

1197
  def stepCheckCategoriesRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
    """
    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)

1210
  def stepRemoveCategories(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1211 1212 1213 1214 1215 1216 1217 1218 1219
    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
1220

Aurel's avatar
Aurel committed
1221
  # sub categories
1222
  def stepCreateSubCategories(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
    """
    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)
1234
    self.failUnless(category is not None)
Aurel's avatar
Aurel committed
1235
    subcategory_list = []
1236
    subcategory_uid_dict = {}
Aurel's avatar
Aurel committed
1237
    for i in xrange(10):
1238
      subcategory = category.newContent(portal_type='Category', title='toto')
Aurel's avatar
Aurel committed
1239 1240
      self.failUnless(subcategory is not None)
      subcategory_list.append(subcategory.getId())
1241 1242 1243 1244 1245
      subcategory_uid_dict[subcategory.getId()] = subcategory.getUid()
    sequence.edit(subcategory_id_list=subcategory_list, \
                  parent_category_id=category.getId(), \
                  subcategory_uid_dict=subcategory_uid_dict)

1246
  def stepModifySubCategories(self, sequence=None, **kw):
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
    """
      Modify the title some subcategories
    """
    base_category_id = sequence.get('bc_id')
    category_tool = self.getCategoryTool()
    base_category = category_tool._getOb(base_category_id, None)
    parent_category_id = sequence.get('parent_category_id')
    category = base_category._getOb(parent_category_id, None)
    subcategory_id_list = sequence.get('subcategory_id_list')
    for subcategory_id in subcategory_id_list:
      subcategory = category._getOb(subcategory_id, None)
      subcategory.edit(title='foo')
1259

1260
  def stepAddSubCategoriesAsPathToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1261 1262 1263 1264 1265 1266 1267
    """
    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
1268

1269
  def stepCheckSubCategoriesExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280
    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)
1281 1282
      self.assertEquals(subcategory.getTitle(), 'toto')

1283
  def stepCheckUidSubCategories(self, sequence=None, **kw):
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299
    """
    Check Uid on base category and the sub categories
    """
    base_category_id = sequence.get('bc_id')
    category_tool = self.getCategoryTool()
    base_category = category_tool._getOb(base_category_id, None)
    self.assertEquals(base_category.getUid(), \
                      sequence.get('base_category_uid'))
    parent_category_id = sequence.get('parent_category_id')
    category = base_category._getOb(parent_category_id, None)
    subcategory_id_list = sequence.get('subcategory_id_list')
    subcategory_uid_dict = sequence.get('subcategory_uid_dict')
    for subcategory_id in subcategory_id_list:
      subcategory = category._getOb(subcategory_id, None)
      self.assertEquals(subcategory.getUid(), \
           subcategory_uid_dict[subcategory_id])
Aurel's avatar
Aurel committed
1300

Aurel's avatar
Aurel committed
1301
  # workflow
1302
  def stepCreateWorkflow(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1303 1304 1305
    """
    Create a workflow
    """
1306
    wf_id = 'geek_workflow'
1307
    pw = self.getWorkflowTool()
1308 1309
    addWorkflowByType(pw, WORKFLOW_TYPE, wf_id)
    workflow = pw._getOb(wf_id, None)
Aurel's avatar
Aurel committed
1310 1311
    self.failUnless(workflow is not None)
    sequence.edit(workflow_id=workflow.getId())
1312 1313 1314 1315 1316
    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)
1317
    props['chain_Geek Object'] = wf_id
1318 1319
    pw.manage_changeWorkflows('', props=props)

1320
  def stepModifyWorkflowChain(self, sequence=None, **kw):
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
    """
    Modify the workflow chain not by business template installation
    """
    wf_id = 'geek_workflow'
    pw = self.getWorkflowTool()
    workflow = pw._getOb(wf_id, None)
    self.failUnless(workflow is not None)
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
        props['chain_%s' % id] = ','.join(wf_ids)
    props['chain_Base Category'] = 'edit_workflow,%s' % wf_id
    pw.manage_changeWorkflows('', props=props)

1336
  def stepSaveWorkflowChain(self, sequence=None, **kw):
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347
    """
    Save the workflow chain as it is
    """
    pw = self.getWorkflowTool()
    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)
    pw.manage_changeWorkflows('', props=props)

1348
  def stepCheckWorkflowChainRemoved(self, sequence=None, **kw):
Christophe Dumez's avatar
Christophe Dumez committed
1349 1350 1351 1352 1353 1354 1355
    """
    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():
1356 1357
        if id == "Geek Object":
          self.assertEqual(len(wf_ids), 0)
Christophe Dumez's avatar
Christophe Dumez committed
1358

1359
  def stepCheckWorkflowChainExists(self, sequence=None, **kw):
1360
    """
1361
    Check if the workflowChain has been added
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371
    """
    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)

1372
  def stepAppendWorkflowToBusinessTemplate(self, sequence=None, **kw):
1373 1374 1375 1376 1377 1378 1379
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    wf_ids = list(bt.getTemplateWorkflowIdList())
    wf_ids.append(sequence.get('workflow_id', ''))
    self.assertEqual(len(wf_ids), 2)
    bt.edit(template_workflow_id_list=wf_ids)

1380
  def stepAddWorkflowToBusinessTemplate(self, sequence=None, **kw):
1381
    """
Aurel's avatar
Aurel committed
1382
    Add workflow to business template
1383
    """
Aurel's avatar
Aurel committed
1384 1385 1386 1387 1388 1389
    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
1390

1391
  def stepAppendWorkflowChainToBusinessTemplate(self, sequence=None, **kw):
1392 1393 1394 1395 1396 1397
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    wf_chain_ids = list(bt.getTemplatePortalTypeWorkflowChainList())
    wf_chain_ids.append('Geek Object | %s' % sequence.get('workflow_id', ''))
    bt.edit(template_portal_type_workflow_chain_list=wf_chain_ids)

1398
  def stepAddWorkflowChainToBusinessTemplate(self, sequence=None, **kw):
Christophe Dumez's avatar
Christophe Dumez committed
1399 1400 1401 1402 1403
    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)

1404
  def stepAddRemovedWorkflowChainToBusinessTemplate(self, sequence=None, **kw):
1405 1406 1407 1408 1409
    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)

1410
  def stepRemoveWorkflow(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1411 1412 1413 1414 1415 1416 1417 1418
    """
    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
1419 1420 1421 1422 1423
    # remove workflowChain
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
1424
        wf_ids = list(wf_ids)
1425
        if wf_id in wf_ids:
1426 1427
          wf_ids.remove(wf_id)
        props['chain_%s' % id] = ','.join(wf_ids)
Christophe Dumez's avatar
Christophe Dumez committed
1428
    pw.manage_changeWorkflows('', props=props)
1429

1430
  def stepCheckWorkflowExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1431 1432 1433 1434 1435 1436 1437
    """
    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)
1438

1439
  def stepCheckWorkflowRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1440 1441 1442 1443 1444 1445 1446
    """
    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)
1447

1448
  def stepCheckWorkflowBackup(self, sequence=None, **kw):
1449 1450 1451 1452 1453 1454 1455 1456 1457
    """
    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
1458
  # Actions
1459
  def stepCreateFirstAction(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1460
    """
Aurel's avatar
Aurel committed
1461
    Create action
Aurel's avatar
Aurel committed
1462 1463 1464 1465
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
1466 1467 1468 1469 1470 1471
    object_pt.newContent(portal_type='Action Information',
                         reference='become_geek',
                         title='Become Geek',
                         action='become_geek_action',
                         action_type='object_action',
                         float_index=2.0)
Aurel's avatar
Aurel committed
1472
    sequence.edit(first_action_id='become_geek')
Aurel's avatar
Aurel committed
1473

1474
  def stepCreateEmptyAction(self, sequence=None, **kw):
1475 1476 1477 1478 1479 1480
    """
    Create an empty action
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
1481 1482 1483 1484
    object_pt.newContent(portal_type='Action Information',
                         title='Name',
                         action_permission_list=(),
                         float_index=1.2)
1485

1486
  def stepCreateSecondAction(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1487
    """
Aurel's avatar
Aurel committed
1488
    Create a second action
Aurel's avatar
Aurel committed
1489 1490 1491 1492
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
1493 1494 1495 1496 1497 1498
    object_pt.newContent(portal_type='Action Information',
                         reference='become_nerd',
                         title='Become Nerd',
                         action='become_nerd_action',
                         action_type='object_action',
                         float_index=1.5)
Aurel's avatar
Aurel committed
1499
    sequence.edit(second_action_id='become_nerd')
Aurel's avatar
Aurel committed
1500

1501
  def stepCheckFirstActionExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1502
    """
Aurel's avatar
Aurel committed
1503
    Check presence of action
Aurel's avatar
Aurel committed
1504 1505 1506 1507
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1508
    action_id = sequence.get('first_action_id')
Julien Muchembled's avatar
Julien Muchembled committed
1509 1510
    self.assertTrue(action_id in [x.getReference()
      for x in object_pt.getActionInformationList()])
1511

1512
  def stepCheckFirstActionNotExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1513
    """
Aurel's avatar
Aurel committed
1514
    Check non-presence of action
Aurel's avatar
Aurel committed
1515 1516 1517 1518
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1519
    action_id = sequence.get('first_action_id')
1520
    self.assertFalse(action_id in [x.getReference()
Julien Muchembled's avatar
Julien Muchembled committed
1521
      for x in object_pt.getActionInformationList()])
1522

1523
  def stepCheckSecondActionExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1524
    """
Aurel's avatar
Aurel committed
1525
    Check presence of the second action
Aurel's avatar
Aurel committed
1526 1527 1528 1529
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1530
    action_id = sequence.get('second_action_id')
Julien Muchembled's avatar
Julien Muchembled committed
1531 1532
    self.assertTrue(action_id in [x.getReference()
      for x in object_pt.getActionInformationList()])
1533

1534
  def stepCheckSecondActionNotExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1535
    """
Aurel's avatar
Aurel committed
1536
    Check non-presence of optional action
Aurel's avatar
Aurel committed
1537 1538 1539 1540
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
Aurel's avatar
Aurel committed
1541
    action_id = sequence.get('second_action_id')
1542
    self.assertFalse(action_id in [x.getReference()
Julien Muchembled's avatar
Julien Muchembled committed
1543
      for x in object_pt.getActionInformationList()])
1544

1545
  def stepAddSecondActionToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1546
    """
Aurel's avatar
Aurel committed
1547
    Add Second Action to business template
Aurel's avatar
Aurel committed
1548
    """
Aurel's avatar
Aurel committed
1549 1550
    object_id = sequence.get('object_ptype_id')
    action_id = sequence.get('second_action_id')
Aurel's avatar
Aurel committed
1551 1552
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
Aurel's avatar
Aurel committed
1553
    bt.edit(template_action_path=['%s | %s' %(object_id, action_id)])
Aurel's avatar
Aurel committed
1554

Aurel's avatar
Aurel committed
1555
  # Catalog Method
1556
  def stepCreateCatalogMethod(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1557 1558 1559 1560
    """
    Create ZSQL Method into catalog
    """
    pc = self.getCatalogTool()
1561
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1562 1563
    self.failUnless(catalog is not None)
    method_id = "z_fake_method"
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1564
    addSQLMethod = catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
1565 1566
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
Aurel's avatar
Aurel committed
1567
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
1568 1569 1570 1571 1572 1573 1574 1575
    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
1576
    expression = 'python: context.isPredicate()'
Aurel's avatar
Aurel committed
1577 1578 1579 1580 1581
    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
1582
    catalog.filter_dict[method_id]['expression_cache_key'] = 'portal_type',
Aurel's avatar
Aurel committed
1583
    catalog.filter_dict[method_id]['type'] = []
Aurel's avatar
Aurel committed
1584

1585
  def stepCreateUpdateCatalogMethod(self, sequence=None, **kw):
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601
    pc = self.getCatalogTool()
    catalog = pc.getSQLCatalog()
    self.failUnless(catalog is not None)
    method_id = "z_fake_method"
    addSQLMethod = catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
    zsql_method = catalog._getOb(method_id, None)
    self.failUnless(zsql_method is not None)
    sequence.edit(zsql_method_id = method_id)
    # set this method in update_object properties of catalog
    sql_uncatalog_object = list(catalog.sql_uncatalog_object)
    sql_uncatalog_object.append(method_id)
    sql_uncatalog_object.sort()
    catalog.sql_uncatalog_object = tuple(sql_uncatalog_object)
    # set filter for this method
1602
    expression = 'python: context.isDelivery()'
1603 1604 1605 1606 1607
    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
1608
    catalog.filter_dict[method_id]['expression_cache_key'] = 'portal_type',
1609 1610
    catalog.filter_dict[method_id]['type'] = []

1611
  def stepCreateNewCatalogMethod(self, sequence=None, **kw):
1612
    pc = self.getCatalogTool()
1613
    catalog = pc.getSQLCatalog()
1614 1615
    method_id = "z_another_fake_method"
    addSQLMethod =catalog.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod
1616 1617
    addSQLMethod(id=method_id, title='', connection_id='erp5_sql_connection',
                 arguments='', template='')
1618 1619 1620 1621 1622 1623 1624 1625 1626
    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)

1627
  def stepChangePreviousCatalogMethod(self, sequence=None, **kw):
1628
    pc = self.getCatalogTool()
1629
    catalog = pc.getSQLCatalog()
1630 1631 1632 1633 1634 1635
    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')

1636
  def stepCheckCatalogMethodChangeKept(self, sequence=None, **kw):
1637
    pc = self.getCatalogTool()
1638
    catalog = pc.getSQLCatalog()
1639 1640 1641 1642
    method_id = sequence.get('zsql_method_id')
    previous_method = catalog._getOb(method_id,None)
    self.assertEquals(previous_method.title,'toto')

1643
  def stepAddCatalogMethodToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1644 1645 1646 1647 1648 1649 1650
    """
    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)
1651 1652 1653
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    bt.edit(template_catalog_method_id_list=[catalog_id+'/'+method_id])
1654

1655
  def stepRemoveCatalogMethodToBusinessTemplate(self, sequence=None, **kw):
1656 1657 1658
    """
    Remove catalog method into the business template
    """
Danièle Vanbaelinghem's avatar
Danièle Vanbaelinghem committed
1659 1660
    business_template = sequence.get('current_bt', None)
    self.assertTrue(business_template is not None)
1661
    method_id = sequence.get('zsql_method_id', None)
Danièle Vanbaelinghem's avatar
Danièle Vanbaelinghem committed
1662 1663 1664 1665 1666 1667
    current_method_list = list(business_template.\
                          getTemplateCatalogMethodIdList())
    catalog_tool = self.getCatalogTool()
    catalog_id = catalog_tool.getSQLCatalog().id
    current_method_list.remove(catalog_id+'/'+method_id)
    business_template.edit(template_catalog_method_id_list=current_method_list)
1668

1669
  def stepAddNewCatalogMethodToBusinessTemplate(self, sequence=None, **kw):
1670 1671 1672 1673 1674 1675 1676 1677
    """
    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)
1678 1679 1680 1681
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    bt.edit(template_catalog_method_id_list=[catalog_id+'/'+method_id,
            catalog_id+'/'+another_method_id])
1682

1683
  def stepCheckCatalogMethodExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1684 1685 1686 1687
    """
    Check presence of ZSQL Method in catalog
    """
    pc = self.getCatalogTool()
1688
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1689 1690
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
1691
    zsql_method = catalog._getOb(method_id, None)
1692
    self.assertNotEqual(zsql_method, None)
Aurel's avatar
Aurel committed
1693 1694 1695 1696 1697
    # check catalog properties
    self.failUnless(method_id in catalog.sql_uncatalog_object)
    # check filter
    filter_dict = catalog.filter_dict[method_id]
    self.assertEqual(filter_dict['filtered'], 1)
1698 1699 1700
    self.assertEqual(filter_dict['expression'], 'python: context.isPredicate()')
    self.assertEqual(filter_dict['expression_cache_key'], ('portal_type',))
    self.assertEqual(filter_dict['type'], ())
1701

1702
  def stepCheckUpdatedCatalogMethodExists(self, sequence=None, **kw):
1703 1704 1705 1706 1707
    pc = self.getCatalogTool()
    catalog = pc.getSQLCatalog()
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
    zsql_method = catalog._getOb(method_id, None)
1708
    self.assertNotEqual(zsql_method, None)
1709 1710 1711 1712 1713
    # check catalog properties
    self.failUnless(method_id in catalog.sql_uncatalog_object)
    # check filter
    filter_dict = catalog.filter_dict[method_id]
    self.assertEqual(filter_dict['filtered'], 1)
1714 1715 1716
    self.assertEqual(filter_dict['expression'], 'python: context.isDelivery()')
    self.assertEqual(filter_dict['expression_cache_key'], ('portal_type',))
    self.assertEqual(filter_dict['type'], ())
1717

1718
  def stepCheckCatalogMethodRemoved(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1719
    """
Aurel's avatar
Aurel committed
1720
    Check non-presence of ZSQL Method in catalog
Romain Courteaud's avatar
Romain Courteaud committed
1721
    """
Aurel's avatar
Aurel committed
1722
    pc = self.getCatalogTool()
1723
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1724 1725
    self.failUnless(catalog is not None)
    method_id = sequence.get('zsql_method_id', None)
Aurel's avatar
Aurel committed
1726
    zsql_method = catalog._getOb(method_id, None)
Aurel's avatar
Aurel committed
1727 1728 1729 1730 1731
    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
1732

1733
  def stepRemoveCatalogMethod(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1734
    """
Aurel's avatar
Aurel committed
1735
    Remove ZSQL Method from catalog
Romain Courteaud's avatar
Romain Courteaud committed
1736
    """
Aurel's avatar
Aurel committed
1737
    pc = self.getCatalogTool()
1738
    catalog = pc.getSQLCatalog()
Aurel's avatar
Aurel committed
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751
    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
1752
    self.failUnless(method_id not in catalog.filter_dict.keys())
Romain Courteaud's avatar
Romain Courteaud committed
1753

Aurel's avatar
Aurel committed
1754
  # Related key, Result key and table, and others
1755
  def stepCreateKeysAndTable(self, sequence=list, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1756
    """
Aurel's avatar
Aurel committed
1757
    Create some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
1758
    """
1759
    # define variables
Aurel's avatar
Aurel committed
1760
    related_key = 'fake_id | category/catalog/z_fake_method'
1761
    result_key = 'catalog.title'
Aurel's avatar
Aurel committed
1762
    result_table = 'fake_catalog'
1763
    search_key = 'fake_search_key | FakeSearchKey'
Aurel's avatar
Aurel committed
1764 1765 1766 1767 1768
    keyword_key = 'fake_keyword'
    full_text_key = 'fake_full_text'
    request_key = 'fake_request'
    multivalue_key = 'fake_multivalue'
    topic_key = 'fake_topic'
1769
    scriptable_key = 'fake_search_text | fake_script_query'
1770 1771
    role_key = 'Foo | catalog.owner'
    local_role_key = 'Bar | catalog.owner'
Aurel's avatar
Aurel committed
1772 1773
    catalog = self.getCatalogTool().getSQLCatalog()
    self.failUnless(catalog is not None)
1774
    # result table
1775 1776 1777 1778 1779
    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)
1780
    self.failUnless(result_table in catalog.sql_search_tables)
Aurel's avatar
Aurel committed
1781
    # result key
1782 1783 1784 1785 1786
    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
1787 1788
    self.failUnless(result_key in catalog.sql_search_result_keys)
    # related key
1789 1790 1791 1792 1793
    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
1794
    self.failUnless(related_key in catalog.sql_catalog_related_keys)
1795 1796 1797 1798 1799 1800 1801
    # search keys
    if search_key not in catalog.sql_catalog_search_keys:
      sql_catalog_search_keys = list(catalog.sql_catalog_search_keys)
      sql_catalog_search_keys.append(search_key)
      sql_catalog_search_keys.sort()
      catalog.sql_catalog_search_keys = tuple(sql_catalog_search_keys)
    self.failUnless(search_key in catalog.sql_catalog_search_keys)
Aurel's avatar
Aurel committed
1802
    # keyword keys
1803 1804 1805 1806 1807
    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
1808 1809
    self.failUnless(keyword_key in catalog.sql_catalog_keyword_search_keys)
    # full_text keys
1810 1811 1812 1813 1814
    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
1815 1816
    self.failUnless(full_text_key in catalog.sql_catalog_full_text_search_keys)
    # request
1817 1818 1819 1820 1821
    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
1822 1823
    self.failUnless(request_key in catalog.sql_catalog_request_keys)
    # multivalue
1824 1825 1826 1827 1828
    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
1829 1830
    self.failUnless(multivalue_key in catalog.sql_catalog_multivalue_keys)
    # topic keys
1831 1832 1833 1834 1835
    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
1836
    self.failUnless(topic_key in catalog.sql_catalog_topic_search_keys)
1837 1838 1839 1840 1841 1842 1843
    # 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)
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858
    # 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)

Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
1859
    sequence.edit(related_key=related_key, result_key=result_key,
1860
                  result_table=result_table, search_key=search_key,
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
1861
                  keyword_key=keyword_key, full_text_key=full_text_key,
1862
                  request_key=request_key,
1863
                  multivalue_key=multivalue_key, topic_key=topic_key, \
1864 1865
                  scriptable_key=scriptable_key,
                  role_key=role_key, local_role_key=local_role_key)
Aurel's avatar
Aurel committed
1866

1867 1868 1869 1870 1871
  def stepModifyCatalogConfiguration(self, sequence, **kw):
    """Modify the current configuration of the catalog.
    """
    catalog = self.getCatalogTool().getSQLCatalog()
    # modify method related configuration
1872 1873
    copy_data = catalog.manage_copyObjects(ids=["z_getitem_by_uid"])
    ids = catalog.manage_pasteObjects(copy_data)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
1874
    new_id = ids[0]['new_id']
1875 1876 1877 1878 1879
    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'
1880 1881 1882 1883
    # modify table related configuration
    catalog.sql_search_tables = tuple( list(catalog.sql_search_tables) +
                                     ['translation'] )
    # modify column related configuration
1884 1885 1886
    catalog.sql_search_result_keys = tuple( list(catalog.sql_search_result_keys) +
                                     ['catalog.reference'] )
    sequence.edit(result_key='catalog.reference', search_table="translation")
1887 1888 1889 1890 1891 1892 1893

  def stepCheckCatalogConfigurationKept(self, sequence, **kw):
    """Check modification made in stepModifyCatalogConfiguration are still
    present.
    """
    catalog = self.getCatalogTool().getSQLCatalog()
    # method related configuration
1894
    self.assertEquals(catalog.sql_getitem_by_uid, 'z_getitem_by_uid_2')
1895 1896 1897
    # table related configuration
    self.failUnless('translation' in catalog.sql_search_tables)
    # column related configuration
1898
    self.failUnless('catalog.reference'
1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
                    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)
1923

1924
  def stepAddKeysAndTableToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935
    """
    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)
1936 1937
    search_key = sequence.get('search_key', None)
    self.failUnless(search_key is not None)
Aurel's avatar
Aurel committed
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
    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)
1948 1949
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1950 1951 1952 1953
    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
1954

Aurel's avatar
Aurel committed
1955 1956
    bt.edit(template_catalog_related_key_list=[related_key],
            template_catalog_result_key_list=[result_key],
Aurel's avatar
Aurel committed
1957
            template_catalog_result_table_list=[result_table],
1958
            template_catalog_search_key_list=[search_key],
Aurel's avatar
Aurel committed
1959 1960 1961 1962 1963
            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],
1964
            template_catalog_scriptable_key_list=[scriptable_key],
1965 1966
            template_catalog_role_key_list=[role_key],
            template_catalog_local_role_key_list=[local_role_key],
Aurel's avatar
Aurel committed
1967
            )
Romain Courteaud's avatar
Romain Courteaud committed
1968

1969
  def stepRemoveKeysAndTable(self, sequence=list, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
1970
    """
Aurel's avatar
Aurel committed
1971
    Remove some keys and tables
Romain Courteaud's avatar
Romain Courteaud committed
1972
    """
Aurel's avatar
Aurel committed
1973 1974 1975 1976 1977 1978
    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)
1979 1980
    search_key = sequence.get('search_key', None)
    self.failUnless(search_key is not None)
Aurel's avatar
Aurel committed
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
    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)
1991 1992
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
1993 1994 1995 1996
    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
1997

Aurel's avatar
Aurel committed
1998
    catalog = self.getCatalogTool().getSQLCatalog()
Aurel's avatar
Aurel committed
1999
    self.failUnless(catalog is not None)
Aurel's avatar
Aurel committed
2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
    # 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)
2018 2019 2020 2021 2022 2023
    # search keys
    sql_catalog_search_keys = list(catalog.sql_catalog_search_keys)
    sql_catalog_search_keys.remove(search_key)
    sql_catalog_search_keys.sort()
    catalog.sql_catalog_search_keys = tuple(sql_catalog_search_keys)
    self.failUnless(search_key not in catalog.sql_catalog_search_keys)
Aurel's avatar
Aurel committed
2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053
    # 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)
2054 2055 2056 2057 2058 2059
    # 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)
2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071
    # 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
2072

2073
  def stepCheckKeysAndTableExists(self, sequence=list, **kw):
2074
    """
Aurel's avatar
Aurel committed
2075
    Check presence of some keys and tables
2076
    """
Aurel's avatar
Aurel committed
2077 2078 2079 2080 2081 2082
    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)
2083 2084
    search_key = sequence.get('search_key', None)
    self.failUnless(search_key is not None)
Aurel's avatar
Aurel committed
2085 2086 2087 2088 2089 2090 2091 2092 2093 2094
    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)
2095 2096
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
2097 2098 2099 2100
    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
2101

Aurel's avatar
Aurel committed
2102 2103 2104 2105 2106 2107 2108 2109
    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)
2110 2111
    # search key
    self.failUnless(search_key in catalog.sql_catalog_search_keys)
Aurel's avatar
Aurel committed
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121
    # 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)
2122 2123
    # scriptable key
    self.failUnless(scriptable_key in catalog.sql_catalog_scriptable_keys)
2124 2125 2126 2127
    # 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)
2128

2129
  def stepCheckKeysAndTableRemoved(self, sequence=list, **kw):
2130
    """
Aurel's avatar
Aurel committed
2131
    Check non-presence of some keys and tables
2132
    """
Aurel's avatar
Aurel committed
2133 2134 2135 2136 2137 2138
    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)
2139 2140
    search_key = sequence.get('search_key', None)
    self.failUnless(search_key is not None)
Aurel's avatar
Aurel committed
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150
    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)
2151 2152
    scriptable_key = sequence.get('scriptable_key', None)
    self.failUnless(scriptable_key is not None)
2153 2154 2155 2156
    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
2157

Aurel's avatar
Aurel committed
2158 2159 2160 2161 2162 2163 2164 2165
    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)
2166 2167
    # search key
    self.failUnless(search_key not in catalog.sql_catalog_search_keys)
Aurel's avatar
Aurel committed
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177
    # 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)
2178 2179
    # scriptable key
    self.failUnless(scriptable_key not in catalog.sql_catalog_scriptable_keys)
2180 2181 2182 2183
    # 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)
2184

Aurel's avatar
Aurel committed
2185
  # Roles
2186
  def stepCreateRole(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2187
    """
Aurel's avatar
Aurel committed
2188
    Create a role
Romain Courteaud's avatar
Romain Courteaud committed
2189
    """
Aurel's avatar
Aurel committed
2190 2191 2192 2193 2194 2195 2196
    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
2197

2198
  def stepRemoveRole(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2199
    """
Aurel's avatar
Aurel committed
2200
    Remove a role
Romain Courteaud's avatar
Romain Courteaud committed
2201
    """
Aurel's avatar
Aurel committed
2202 2203 2204 2205 2206 2207 2208
    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
2209

2210
  def stepAddRoleToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2211 2212 2213 2214 2215 2216 2217 2218 2219
    """
    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])

2220
  def stepCheckRoleExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2221 2222 2223 2224 2225 2226 2227
    """
    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
2228

2229
  def stepCheckRoleRemoved(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2230
    """
Aurel's avatar
Aurel committed
2231
    Check non-presence of role
Romain Courteaud's avatar
Romain Courteaud committed
2232
    """
Aurel's avatar
Aurel committed
2233 2234 2235 2236
    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
2237

Aurel's avatar
Aurel committed
2238
  # Local Roles
2239
  def stepCreateLocalRoles(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2240 2241 2242
    """
    Create local roles
    """
Jérome Perrin's avatar
Jérome Perrin committed
2243 2244
    new_local_roles = {'ac':['Owner', 'Manager'],
                       'group_function': ['Auditor']}
Aurel's avatar
Aurel committed
2245
    p = self.getPortal()
Aurel's avatar
Aurel committed
2246 2247 2248 2249 2250
    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
    self.assertEquals(module.__ac_local_roles__, new_local_roles)
2251
    sequence.edit(local_roles=new_local_roles)
Aurel's avatar
Aurel committed
2252

2253
  def stepRemoveLocalRoles(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2254 2255 2256
    """
    Remove local roles
    """
Aurel's avatar
Aurel committed
2257
    p = self.getPortal()
Aurel's avatar
Aurel committed
2258 2259 2260
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
Jérome Perrin's avatar
Jérome Perrin committed
2261
    module.__ac_local_roles__ = {'someone_else': ['Associate']}
Aurel's avatar
Aurel committed
2262 2263 2264
    new_local_roles = sequence.get('local_roles')
    self.assertNotEquals(module.__ac_local_roles__, new_local_roles)

2265
  def stepAddLocalRolesToBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2266 2267 2268 2269 2270 2271 2272 2273
    """
    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])

2274
  def stepCheckLocalRolesExists(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2275 2276 2277 2278 2279 2280 2281 2282 2283
    """
    Check presence of local roles
    """
    new_local_roles = sequence.get('local_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)
Aurel's avatar
Aurel committed
2284

2285
  def stepCheckModuleLocalRolesInCatalogBeforeUpdate(self, sequence=None, **kw):
2286 2287 2288 2289 2290 2291 2292 2293 2294 2295
    p = self.getPortal()
    module_id = sequence.get('module_id')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    sql = "select distinct roles_and_users.uid as uid, allowedRolesAndUsers as role from catalog, roles_and_users where catalog.security_uid = roles_and_users.uid and catalog.uid=%s" %(module.getUid(),)
    sql_connection = self.getSQLConnection()
    result = sql_connection.manage_test(sql)
    result = [(x.uid, x.role) for x in result]
    sequence.edit(local_roles_catalog_result=result)

2296
  def stepCheckModuleLocalRolesInCatalogAfterUpdate(self, sequence=None, **kw):
2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
    p = self.getPortal()
    module_id = sequence.get('module_id')
    before_update_local_roles = sequence.get('local_roles_catalog_result')
    module = p._getOb(module_id, None)
    self.failUnless(module is not None)
    sql = "select distinct roles_and_users.uid as uid, allowedRolesAndUsers as role from catalog, roles_and_users where catalog.security_uid = roles_and_users.uid and catalog.uid=%s" %(module.getUid(),)
    sql_connection = self.getSQLConnection()
    result = sql_connection.manage_test(sql)
    for line in result:
      self.assertTrue((line.uid, line.role) not in before_update_local_roles)

2308
  def stepCheckLocalRolesRemoved(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2309 2310 2311 2312 2313 2314 2315 2316 2317 2318
    """
    Check non-presence of local roles
    """
    new_local_roles = sequence.get('local_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)

Aurel's avatar
Aurel committed
2319 2320
  # Document, Property Sheet, Extension And Test
  # they use the same class so only one test is required for them
2321
  def stepCreatePropertySheet(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2322
    """
Aurel's avatar
Aurel committed
2323
    Create a Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
2324
    """
Aurel's avatar
Aurel committed
2325 2326
    ps_title = 'UnitTest'
    ps_data =  ' \nclass UnitTest: \n  """ \n  Fake property sheet for unit test \n \
2327
    """ \n  _properties = ({"id": "ps_prop1", "type": "string"},) \n  _categories = ( \n  ) \n\n'
Romain Courteaud's avatar
Romain Courteaud committed
2328
    cfg = getConfiguration()
Aurel's avatar
Aurel committed
2329 2330 2331 2332 2333 2334 2335
    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))
2336
    sequence.edit(ps_title=ps_title, ps_path=file_path, ps_data=ps_data)
Romain Courteaud's avatar
Romain Courteaud committed
2337

2338
  def stepAddPropertySheetToBusinessTemplate(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2339
    """
Aurel's avatar
Aurel committed
2340
    Add Property Sheet to Business Template
Romain Courteaud's avatar
Romain Courteaud committed
2341
    """
Aurel's avatar
Aurel committed
2342 2343 2344 2345 2346
    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
2347

2348
  def stepCheckPropertySheetMigration(self, sequence=None, **kw):
2349 2350 2351 2352
    """
    Check migration of Property Sheets from the Filesystem to ZODB
    """
    property_sheet_tool = self.getPortalObject().portal_property_sheets
2353
    self.failUnless('UnitTest' in property_sheet_tool.objectIds())
2354 2355 2356 2357 2358 2359 2360

    property_list = property_sheet_tool.UnitTest.contentValues()

    self.assertEquals(len(property_list), 1)
    self.failUnless(property_list[0].getReference() == 'ps_prop1')
    self.failUnless(property_list[0].getElementaryType() == 'string')

Aurel's avatar
Aurel committed
2361
  def stepRemovePropertySheet(self, sequence=None, sequencer_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2362
    """
Aurel's avatar
Aurel committed
2363
    Remove Property Sheet
Romain Courteaud's avatar
Romain Courteaud committed
2364
    """
2365
    ps_title = sequence.get('ps_title', None)
Aurel's avatar
Aurel committed
2366 2367 2368 2369 2370
    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))
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391
    return
    # Property Sheet will not be installed in file sytem
    self.failIf(os.path.exists(ps_path))
    # Property Sheet will be installed in ZODB
    self.failUnless(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)
    self.portal.portal_property_sheets.manage_delObjects([ps_title])
    self.failIf(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)

  def stepRemovePropertySheetFromZODB(self, sequence=None, sequencer_list=None, **kw):
    """
    Remove Property Sheet from ZODB
    """
    ps_title = sequence.get('ps_title', None)
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
    # Property Sheet will not be installed in file sytem
    self.failIf(os.path.exists(ps_path))
    # Property Sheet will be installed in ZODB
    self.failUnless(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)
    self.portal.portal_property_sheets.manage_delObjects([ps_title])
    self.failIf(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)
2392

Aurel's avatar
Aurel committed
2393 2394 2395 2396
  def stepCheckPropertySheetExists(self, sequence=None, sequencer_list=None, **kw):
    """
    Check presence of Property Sheet
    """
2397
    ps_title = sequence.get('ps_title', None)
Aurel's avatar
Aurel committed
2398 2399
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
2400 2401 2402 2403
    # Property Sheet will not be installed in file sytem
    self.failIf(os.path.exists(ps_path))
    # Property Sheet will be installed in ZODB
    self.failUnless(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)
2404

Aurel's avatar
Aurel committed
2405
  def stepCheckPropertySheetRemoved(self, sequence=None, sequencer_list=None, **kw):
2406
    """
2407
    Check deletion of Property Sheet
Aurel's avatar
Aurel committed
2408 2409 2410 2411
    """
    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
2412

2413
  def stepCheckMigratedPropertySheetRemoved(self, sequence=None, **kw):
2414 2415 2416 2417 2418
    """
    Check deletion of migrated Property Sheet
    """
    ps_id = sequence.get('ps_title', None)
    self.failIf(ps_id is None)
2419
    self.failIf(ps_id in self.getPortalObject().portal_property_sheets.objectIds())
2420

2421
  def stepCreateUpdatedPropertySheet(self, sequence=None, **kw):
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441
    """
    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
    """
2442
    ps_title = sequence.get('ps_title', None)
2443 2444
    ps_path = sequence.get('ps_path', None)
    self.failUnless(ps_path is not None)
2445 2446 2447 2448
    # Property Sheet will not be installed in file sytem
    self.failIf(os.path.exists(ps_path))
    # Property Sheet will be installed in ZODB
    self.failUnless(getattr(self.portal.portal_property_sheets, ps_title, None) is not None)
2449

Aurel's avatar
Aurel committed
2450
  # Busines templates
2451
  def stepImportBusinessTemplate(self, sequence=None, **kw):
2452
    """
Aurel's avatar
Aurel committed
2453 2454 2455
    Import Business Template from a dir
    """
    template_path = sequence.get('template_path')
2456
    template_tool = self.getTemplateTool()
Aurel's avatar
Aurel committed
2457 2458 2459 2460
    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
2461
      n = n + 1
Aurel's avatar
Aurel committed
2462 2463 2464 2465 2466 2467
      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
2468

2469
  def stepAddExtraSlashesToTemplatePath(self, sequence=None, **kw):
2470 2471 2472 2473 2474
    """Add extra slashes to the template path for testing.
    """
    template_path = sequence.get('template_path')
    sequence.edit(template_path = template_path + '//')

2475
  def stepInstallBusinessTemplate(self, sequence=None, **kw):
Aurel's avatar
Aurel committed
2476
    """
2477
    Install imported business template
Aurel's avatar
Aurel committed
2478 2479 2480
    """
    import_bt = sequence.get('import_bt')
    import_bt.install(force=1)
2481

2482
  def stepReinstallBusinessTemplate(self, sequence=None, **kw):
2483
    import_bt = sequence.get('current_bt')
2484 2485 2486 2487 2488
    listbox_object_list = import_bt.BusinessTemplate_getModifiedObject()
    install_kw = {}
    for listbox_line in listbox_object_list:
      install_kw[listbox_line.object_id] = listbox_line.choice_item_list[0][1]
    import_bt.reinstall(object_to_update=install_kw)
Nicolas Delaby's avatar
Nicolas Delaby committed
2489

2490
  def stepCheckBeforeReinstall(self, sequence=None, **kw):
Nicolas Delaby's avatar
Nicolas Delaby committed
2491
    import_bt = sequence.get('current_bt')
2492
    diff_list = import_bt.BusinessTemplate_getModifiedObject()
Julien Muchembled's avatar
Julien Muchembled committed
2493 2494
    self.assertTrue('portal_types/Geek Object/become_geek'
                    in [line.object_id for line in diff_list])
2495

2496
  def stepInstallCurrentBusinessTemplate(self, sequence=None, **kw):
2497 2498 2499
    import_bt = sequence.get('current_bt')
    import_bt.install(force=1)

2500
  def stepInstallWithoutForceBusinessTemplate(self, sequence=None, **kw):
2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514
    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
2515 2516
    import_bt.install(force=0, object_to_update=install_object_dict,
                      update_catalog=1)
2517

2518
  def stepInstallWithRemoveCheckedBusinessTemplate(self, sequence=None, **kw):
2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535
    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 in ('Removed', 'Removed but used'):
        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,
                      update_catalog=1)

2536
  def stepInstallDuplicatedBusinessTemplate(self, sequence=None, **kw):
2537 2538 2539 2540 2541 2542
    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)

2543
  def stepPartialCatalogMethodInstall(self, sequence=None, **kw):
2544
    import_bt = sequence.get('import_bt')
2545 2546 2547
    pc = self.getCatalogTool()
    catalog_id = pc.getSQLCatalog().id
    object_to_update = {'portal_catalog/'+catalog_id+'/z_another_fake_method':'install'}
2548 2549
    import_bt.install(object_to_update=object_to_update)

2550
  def stepCreateNewBusinessTemplate(self, sequence=None, **kw):
2551
    """
Aurel's avatar
Aurel committed
2552
    Create a new Business Template
2553
    """
Aurel's avatar
Aurel committed
2554 2555 2556 2557 2558 2559 2560 2561
    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)
2562

2563
  def stepCreateSecondBusinessTemplate(self, sequence=None, **kw):
2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575
    """
    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)

2576
  def stepCreateDuplicatedBusinessTemplate(self, sequence=None, **kw):
2577
    """
2578 2579
    Create a new Business Template which will duplicate
    the configuration.
2580
    """
2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591
    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'))

2592
  def stepBuildBusinessTemplateFail(self, sequence=None, **kw):
2593 2594 2595
    template = sequence.get('current_bt')
    self.assertRaises(AttributeError,
                      template.build)
2596

2597
  def stepCheckBuildWithBadPortalTypeFailed(self, sequence=None, **kw):
2598 2599 2600 2601
    template = sequence.get('current_bt')
    self.assertRaises(ValueError,
                      template.build)

2602
  def stepBuildBusinessTemplate(self, sequence=None, **kw):
2603
    """
Aurel's avatar
Aurel committed
2604
    Build Business Template
2605
    """
Aurel's avatar
Aurel committed
2606
    template = sequence.get('current_bt')
Aurel's avatar
Aurel committed
2607
    template.build()
Romain Courteaud's avatar
Romain Courteaud committed
2608

2609
  def stepEditBusinessTemplate(self, sequence=None, **kw):
2610 2611 2612 2613 2614 2615
    """
    Edit Business Template
    """
    template = sequence.get('current_bt')
    template.edit()

2616
  def stepSaveBusinessTemplate(self, sequence=None, **kw):
Yoshinori Okuji's avatar
Yoshinori Okuji committed
2617
    """
Aurel's avatar
Aurel committed
2618
    Export Business Template
Yoshinori Okuji's avatar
Yoshinori Okuji committed
2619
    """
Aurel's avatar
Aurel committed
2620 2621 2622 2623
    template = sequence.get('current_bt')
    cfg = getConfiguration()
    bt_title = pathname2url(template.getTitle())
    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (bt_title,))
2624
    # remove previous version of bt it exists
2625 2626
    if os.path.exists(template_path):
      shutil.rmtree(template_path)
Aurel's avatar
Aurel committed
2627 2628 2629
    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
2630

2631
  def stepCheckObjectPropertiesInBusinessTemplate(self, sequence=None, **kw):
2632
    """
Aurel's avatar
Aurel committed
2633
    Check that ac_local_roles, uid and _owner are set to None
2634
    """
Aurel's avatar
Aurel committed
2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654
    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)
2655

2656
  def stepCheckUnindexActivityPresence(self, sequence=None, **kw):
2657 2658 2659
    """
    Check if we have activity for unindex
    """
2660 2661 2662 2663
    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)
2664

2665
  def stepCheckFolderReindexActivityPresence(self, sequence=None, **kw):
2666 2667 2668 2669 2670 2671 2672
    """
    Check if we have activity for Folder_reindexAll.
    """
    message_list = [ m for m in self.portal.portal_activities.getMessageList()
                     if m.method_id == 'Folder_reindexAll']
    self.assertNotEquals(len(message_list), 0)

2673
  def stepCheckPathNotUnindexAfterBuild(self, sequence=None, **kw):
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
    """
    Check that after a build, not unindex has been done
    """
    bc_id = sequence.get('bc_id')
    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)

2688
  def stepSetUpdateToolFlagInBusinessTemplate(self, sequence=None):
Aurel's avatar
Aurel committed
2689
    """
Aurel's avatar
Aurel committed
2690
    Set flag for update in Business Template
Aurel's avatar
Aurel committed
2691 2692 2693 2694 2695 2696
    """
    bt = sequence.get('current_bt')
    self.assertEqual(bt.getTitle(),'erp5_core')
    bt.edit(template_update_tool=1)
    self.assertEqual(bt.getTemplateUpdateTool(), 1)

2697
  def stepRemoveBusinessTemplate(self, sequence=None, **kw):
2698
    """
Aurel's avatar
Aurel committed
2699
    Remove current Business Template
2700
    """
Aurel's avatar
Aurel committed
2701 2702 2703 2704 2705 2706
    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)

2707
  def stepUninstallBusinessTemplate(self, sequence=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
2708
    """
Aurel's avatar
Aurel committed
2709
    Uninstall current Business Template
Romain Courteaud's avatar
Romain Courteaud committed
2710
    """
Aurel's avatar
Aurel committed
2711 2712 2713
    bt = sequence.get('current_bt')
    bt.uninstall()

2714
  def stepUninstallPreviousBusinessTemplate(self, sequence=None, **kw):
2715 2716 2717
    bt = sequence.get('previous_bt')
    bt.uninstall()

2718
  def stepClearBusinessTemplateField(self, sequence=None, **kw):
2719 2720 2721 2722 2723 2724 2725 2726 2727
    """
    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',
2728 2729 2730 2731 2732
                 'install_object_list_list', 'title', 'version', 'description',
                 'template_portal_type_allowed_content_type_list',
                 'template_portal_type_hidden_content_type_list',
                 'template_portal_type_property_sheet_list',
                 'template_portal_type_base_category_list'):
2733 2734 2735 2736 2737 2738 2739 2740 2741
          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)

2742
  def stepRemoveSimulationTool(self, sequence=None, **kw):
2743
    p = self.getPortal()
2744 2745
    p.manage_delObjects(['portal_simulation'])
    self.failUnless(p._getOb('portal_simulation', None) is None)
2746

2747
  def stepCheckSimulationToolExists(self, sequence=None, **kw):
2748
    self.failUnless(self.getSimulationTool() is not None)
Aurel's avatar
Aurel committed
2749

2750
  def stepCheckSubobjectsNotIncluded(self, sequence=None, **kw):
2751 2752 2753 2754 2755 2756 2757 2758 2759
    """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)
2760

2761
  def stepCheckInitialRevision(self, sequence=None, **kw):
2762 2763
    """ Check if revision of a new bt is an empty string
    """
2764
    bt = sequence.get('current_bt')
2765
    self.assertEqual(bt.getRevision(), '')
2766

2767
  def stepCheckFirstRevision(self, sequence=None, **kw):
2768 2769
    """ Check if revision of the bt is 1
    """
2770
    bt = sequence.get('current_bt')
2771
    self.assertEqual(bt.getRevision(), '1')
2772

2773
  def stepCheckSecondRevision(self, sequence=None, **kw):
2774 2775
    """ Check if revision of the bt is 2
    """
2776
    bt = sequence.get('current_bt')
2777
    self.assertEqual(bt.getRevision(), '2')
2778

2779
  def stepCheckNoMissingDependencies(self, sequence=None, **kw):
2780 2781 2782 2783 2784 2785 2786 2787 2788
    """ 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)
2789

2790
  def stepCheckMissingDependencies(self, sequence=None, **kw):
2791 2792 2793 2794 2795 2796 2797 2798 2799
    """ 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)
2800

2801
  def stepAddDependency(self, sequence=None, **kw):
2802 2803 2804 2805
    """ Add a dependency to the business template
    """
    bt = sequence.get('current_bt')
    bt.setDependencyList(['dependency_bt',])
2806

2807
  def stepCreateDependencyBusinessTemplate(self, sequence=None, **kw):
2808 2809 2810 2811 2812 2813 2814 2815
    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)
2816

Arnaud Fontaine's avatar
Arnaud Fontaine committed
2817
  def stepSetSkinFolderRegisteredSelections(self, sequence=None, **kw):
2818 2819 2820 2821 2822 2823
    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')
2824

Arnaud Fontaine's avatar
Arnaud Fontaine committed
2825
  def stepSetSkinFolderRegisteredSelections2(self, sequence=None, **kw):
2826 2827 2828 2829 2830
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    skin_folder._updateProperty(
          'business_template_registered_skin_selections', ('Foo', 'Bar',))
2831

2832 2833 2834
  def stepCreateSkinSelection(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    ps.manage_skinLayers(skinpath=('erp5_core',), skinname='Foo', add_skin=1)
2835

Arnaud Fontaine's avatar
Arnaud Fontaine committed
2836
  def stepSetStaticSkinFolderRegisteredSelections(self, sequence=None, **kw):
2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848
    ps = self.getSkinsTool()
    skin_id = sequence.get('static_skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    skin_folder._setProperty(
          'business_template_registered_skin_selections', ('Foo',),
          type='tokens')
    selection = ps.getSkinPath('Foo')
    selection = selection.split(',')
    if skin_id not in selection:
      selection.append(skin_id)
      ps.manage_skinLayers(skinpath=tuple(selection),
                           skinname='Foo', add_skin=1)
2849

2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863
  def stepCheckSkinSelectionAdded(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    # 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)
    skin_folder = ps._getOb(skin_id, None)
    skin_selection_list = skin_folder.getProperty(
        'business_template_registered_skin_selections', ())
    self.assertTrue('Foo' in skin_selection_list)
2864

2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876
  def stepCheckStaticSkinSelection(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    static_skin_id = sequence.get('static_skin_folder_id')
    # 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)
    self.assertTrue(static_skin_id in layers, layers)
Aurel's avatar
Aurel committed
2877

2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 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 2992 2993 2994 2995 2996 2997 2998 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 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 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 3085 3086 3087 3088 3089 3090 3091 3092 3093 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 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 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 3186 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 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 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 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 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 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 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 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 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 3400 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 3431 3432 3433 3434 3435 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
  def stepCreateCustomWorkflow(self, sequence=None, **kw):
    """
    Create a custom workflow
    """
    wf_id = 'custom_geek_workflow'
    pw = self.getWorkflowTool()
    addWorkflowByType(pw, WORKFLOW_TYPE, wf_id)
    workflow = pw._getOb(wf_id, 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,%s' % (props[key], wf_id)
    else:
      props[key] = wf_id
    pw.manage_changeWorkflows('', props=props)

  def stepCreateCustomBusinessTemplate(self, sequence=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, **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, **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, **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))

  def stepCopyBusinessTemplate(self, sequence=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, **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, **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 stepCreatePortalTypeRole(self, sequence=None, **kw):
    """
    Create portal type role
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    object_pt = pt._getOb(object_id)
    object_pt.newContent(portal_type='Role Information',
      title='Geek Role Definition',
      description='A definition with non ascii chars éàè',
      role_name_list=('geek_role_definition',),
      role_category_list=('group/g1','function/f1'),
      role_base_category_script_id='Base Category Script',
      role_base_category_list=('group','site'))

    sequence.edit(portal_type_role='geek_role_definition')

  def stepAddPortalTypeRolesToBusinessTemplate(self, sequence=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, **kw):
    """
    Cehck that portal type role exist
    """
    pt = self.getTypeTool()
    object_id = sequence.get('object_ptype_id')
    role, = pt[object_id].getRoleInformationList()
    self.assertEqual('Geek Role Definition', role.getTitle())
    self.assertEqual(['geek_role_definition'], role.getRoleNameList())
    self.assertEqual('A definition with non ascii chars éàè', role.getDescription())
    self.assertEqual(['group/g1','function/f1'], role.getRoleCategoryList())
    self.assertEqual(['group','site'], role.getRoleBaseCategoryList())
    self.assertEqual('Base Category Script', role.getRoleBaseCategoryScriptId())

  def stepModifyPortalType(self, sequence=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, **kw):
    """
    Unmodify Portal Type
    """
    pt = self.getTypeTool()
    object_type = pt._getOb('Geek Object', None)
    object_type.title = object_type.title[len('Modified '):]

  def stepCheckModifiedPortalTypeExists(self, sequence=None, **kw):
    """
    Check presence of modified portal type
    """
    self.stepCheckPortalTypeExists(sequence=sequence, **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 stepCreateFakeZODBScript(self, sequence=None, **kw):
    """Create a Script inside portal_skins
    """
    grain_of_sand = ''.join([random.choice(string.ascii_letters) for i in xrange(10)])
    python_script_id = 'ERP5Site_dummyScriptWhichRandomId%s' % grain_of_sand
    skin_folder_id = 'custom'
    if getattr(self.portal.portal_skins, skin_folder_id, None) is None:
        self.portal.portal_skins.manage_addProduct['OFSP'].manage_addFolder(skin_folder_id)
    skin_folder = self.portal.portal_skins[skin_folder_id]
    skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(
                                                                 id=python_script_id)
    sequence.set('python_script_id', python_script_id)
    sequence.set('skin_folder_id', skin_folder_id)

  def stepAddCustomSkinFolderToBusinessTemplate(self, sequence=None, **kw):
    """
    Add types to business template
    """
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    template_skin_id_list = list(bt.getProperty('template_skin_id_list'))
    template_skin_id_list.append('custom')
    bt.edit(template_skin_id_list=template_skin_id_list)

  def stepCheckFakeScriptIsDeleted(self, sequence=None, **kw):
    """Check that script inside ZODB is deleted by BT reinstallation
    """
    python_script_id = sequence.get('python_script_id')
    skin_folder_id = sequence.get('skin_folder_id')
    folder = self.portal.portal_skins[skin_folder_id]
    self.assertTrue(python_script_id not in folder.objectIds())

  def stepSetOldSitePropertyValue(self, sequence=None, **kw):
    """Set the old value to a site property."""
    sequence.set('site_property_value', 'old')

  def stepSetNewSitePropertyValue(self, sequence=None, **kw):
    """Set the new value to a site property."""
    sequence.set('site_property_value', 'new')

  def stepCreateSiteProperty(self, sequence=None, **kw):
    """Create a site property."""
    portal = self.getPortal()
    portal._setProperty('a_property', sequence.get('site_property_value'))

  def stepModifySiteProperty(self, sequence=None, **kw):
    """Modify a site property."""
    portal = self.getPortal()
    portal._updateProperty('a_property', sequence.get('site_property_value'))

  def stepCheckSiteProperty(self, sequence=None, **kw):
    """Check a site property."""
    portal = self.getPortal()
    self.assertEquals(portal.getProperty('a_property'),
                      sequence.get('site_property_value'))

  def stepCheckSitePropertyRemoved(self, sequence=None, **kw):
    """Check if a site property is removed."""
    portal = self.getPortal()
    self.failIf(portal.hasProperty('a_property'))

  def stepAddSitePropertyToBusinessTemplate(self, sequence=None, **kw):
    """Add a site property into a business template."""
    bt = sequence.get('current_bt', None)
    self.failUnless(bt is not None)
    bt.edit(template_site_property_id_list=('a_property',))

  def stepCheckSkinSelectionRemoved(self, sequence=None, **kw):
    """
    Check that a skin selection has been removed.
    """
    self.assertTrue('Foo' not in self.portal.portal_skins.getSkinSelections())

  def stepCheckSkinSelectionNotRemoved(self, sequence=None, **kw):
    """
    Check that a skin selection has not been removed.
    """
    self.assertTrue('Foo' in self.portal.portal_skins.getSkinSelections())

  def stepUserDisableSkinSelectionRegistration(self, sequence=None, **kw):
    """
    Simulate User disabling skin registration from UI.
    """
    self.app.REQUEST.set('your_register_skin_selection', 0)

  def stepUserSelectSkinToBeChanged(self, sequence=None, **kw):
    """
    User selects skin to be changed from UI.
    """
    select_skin_to_be_changed_list = self.portal.portal_skins.getSkinSelections()[:1]
    select_skin_not_to_be_changed_list = self.portal.portal_skins.getSkinSelections()[1:]
    sequence.edit(select_skin_to_be_changed_list = select_skin_to_be_changed_list, \
                  select_skin_not_to_be_changed_list = select_skin_not_to_be_changed_list)
    self.app.REQUEST.set('your_skin_layer_list', select_skin_to_be_changed_list)

  def stepCheckUserSelectedSkinToBeChanged(self, sequence=None, **kw):
    """
    Check that only selected to be changed skins are affected.
    """
    skin_folder_id = sequence.get('skin_folder_id')
    select_skin_to_be_changed_list = sequence.get('select_skin_to_be_changed_list')
    select_skin_not_to_be_changed_list = sequence.get('select_skin_not_to_be_changed_list')
    for skin_name in select_skin_to_be_changed_list:
      self.assertTrue(skin_folder_id in self.portal.portal_skins.getSkinPath(skin_name))
    for skin_name in select_skin_not_to_be_changed_list:
      self.assertTrue(skin_folder_id not in self.portal.portal_skins.getSkinPath(skin_name))

  def stepCheckSkinFolderPriorityOn(self, sequence=None, **kw):
    """
    Check skin folder priority
    """
    ps = self.portal.portal_skins
    for skin in ps.getSkinSelections():
      self.assertEquals('erp5_core', ps.getSkinPath(skin).split(',')[0])
      self.assertEquals('erp5_geek', ps.getSkinPath(skin).split(',')[1])

  def stepCheckSkinFolderPriorityOff(self, sequence=None, **kw):
    """
    Check skin folder priority off
    """
    ps = self.portal.portal_skins
    for skin in ps.getSkinSelections():
      self.assertEquals('erp5_geek', ps.getSkinPath(skin).split(',')[0])
      self.assertEquals('erp5_core', ps.getSkinPath(skin).split(',')[1])

  def stepUserDisableSkinFolderPriority(self, sequence=None, **kw):
    """
    User chooses skin folder priority off from UI
    """
    self.app.REQUEST.set('your_reorder_skin_selection', 0)

  def stepSetExistingSkinFolderPriority(self, sequence=None, **kw):
    """
    Set exisitng skin priority for test
    """
    skin_folder = self.portal.portal_skins['erp5_core']
    if not skin_folder.hasProperty('business_template_skin_layer_priority'):
      skin_folder.manage_addProperty('business_template_skin_layer_priority', \
                                     10000.0, 'float')

  def stepSetBusinessTemplateSkinFolderPriority(self, sequence=None, **kw):
    """
    Set skin folder priority.
    """
    skin_folder_id = sequence.get('skin_folder_id')
    skin_folder = self.portal.portal_skins[skin_folder_id]
    skin_folder.manage_addProperty('business_template_skin_layer_priority', 9999.0, 'float')

  def stepModifySkinFolder(self, sequence=None, **kw):
    """
    Modify the skin folder
    """
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    skin_folder._setProperty(
                    'business_template_skin_layer_priority',
                    99, type='float')
    # Make sure it is really set.
    self.assertEquals(
        99, skin_folder.getProperty('business_template_skin_layer_priority'))

  def stepUnmodifySkinFolder(self, sequence=None, **kw):
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    skin_folder._delProperty('business_template_skin_layer_priority')
    self.assertEquals(
        None, skin_folder.getProperty('business_template_skin_layer_priority'))

  def stepCheckModifiedSkinFolderExists(self, sequence=None, **kw):
    """
    Check modified skin folder
    """
    ps = self.getSkinsTool()
    skin_id = sequence.get('skin_folder_id')
    skin_folder = ps._getOb(skin_id, None)
    self.assertEquals(
        99, skin_folder.getProperty('business_template_skin_layer_priority'))

  def stepCheckDocumentPropertySheetSameName(self, sequence=None, **kw):
    self.assertEqual(sequence['ps_title'], sequence['document_title'])
    self.assertEqual(os.path.basename(sequence['document_path']),
        os.path.basename(sequence['ps_path']))

  def stepRemovePropertySheetFromBusinessTemplate(self, sequence=None, **kw):
    """
    Add Property Sheet to Business Template
    """
    sequence['current_bt'].edit(template_property_sheet_id_list=[])

  def stepCreateAllPropertySheetsFromFilesystem(self, sequence=None, **kw):
    self.portal.portal_property_sheets.createAllPropertySheetsFromFilesystem()

  def stepRemovePropertySheetZodbOnly(self, sequence=None, **kw):
    """
    Remove Property Sheet, but only from ZODB
    """
    self.portal.portal_property_sheets.manage_delObjects([sequence['ps_title']])

  def stepCheckDraftBuildingState(self, sequence=None, **kw):
    self.assertEquals(sequence['current_bt'].getBuildingState(), 'draft')

  def stepSimulateAndCopyPrePropertySheetMigrationBusinessTemplate(self, sequence=None, **kw):
    portal = self.getPortalObject()
    template_tool = portal.portal_templates
    current_bt = sequence['current_bt']
    cb_data = template_tool.manage_copyObjects([current_bt.getId()])
    copied, = template_tool.manage_pasteObjects(cb_data)
    current = current_bt._property_sheet_item._objects.copy()
    current_bt._property_sheet_item._objects = PersistentMapping()
    for k,v in current.iteritems():
      k = k.lstrip('portal_property_sheets/')
      current_bt._property_sheet_item._objects[k] = v
    sequence.edit(current_bt=template_tool._getOb(copied['new_id']))


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

    - Create a template

    - Install a template

    - Uninstall a template

    - Upgrade a template
  """

  def getTitle(self):
    return "Business Template"

  # tests
  def test_Title(self):
    """Tests the Title of the Template Tool."""
    self.assertEquals('Template Tool', self.getTemplateTool().Title())

  def test_01_checkNewSite(self):
    """Test Check New Site"""
    sequence_list = SequenceList()
    sequence_string = '\
                       UseCoreBusinessTemplate  \
                       CheckTools \
                       CheckBuiltBuildingState \
                       CheckInstalledInstallationState \
                       CheckSkinsLayers \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  # test of portal types
  def test_02_BusinessTemplateWithPortalTypes(self):
    """Test Business Template With Portal Types"""
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CreateSecondBusinessTemplate \
                       UseSecondBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       ModifyPortalTypeInBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_021_BusinessTemplateWithPortalTypesAndWrongValues(self):
    """Test Business Template With Portal Types and Bad Values"""
    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)

  # test of skins
  def test_03_BusinessTemplateWithSkins(self):
    """Test Business Template With Skin Folder"""
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveSkinFolder \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckSkinFolderExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSkinFolderRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  # test of workflow
  def test_04_BusinessTemplateWithWorkflow(self):
    """Test Business Template With Workflow"""
    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 \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckWorkflowRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_041_BusinessTemplateWithWorkflowRemoved(self):
    """Test Business Template With Remove Of Workflow"""
    sequence_list = SequenceList()
    sequence_string = '\
3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509
                       CreatePortalType \
                       CreateWorkflow \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveWorkflow \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
3510
                       ModifyWorkflowChain \
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
                       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 \
3536
                       CheckFolderReindexActivityPresence \
3537 3538 3539 3540
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
3541 3542 3543 3544 3545
                       CheckWorkflowExists \
                       CheckWorkflowChainRemoved \
                       SaveWorkflowChain \
                       '
    sequence_list.addSequenceString(sequence_string)
3546
    sequence_list.play(self)
3547

3548 3549
  def test_042_BusinessTemplateWithWorkflowRemoved(self):
    """Test Business Template With Remove Of Workflow"""
3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605
    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 \
                       ModifyWorkflowChain \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckWorkflowExists \
                       CheckWorkflowChainExists \
                       CreateSecondBusinessTemplate \
                       UseSecondBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       Tic \
                       InstallWithRemoveCheckedBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
3606 3607
                       CheckWorkflowRemoved \
                       CheckWorkflowChainRemoved \
3608
                       SaveWorkflowChain \
3609 3610
                       '
    sequence_list.addSequenceString(sequence_string)
3611
    sequence_list.play(self)
3612

3613 3614
  def test_043_BusinessTemplateWithWorkflowChainRemoved(self):
    """Test Business Template With Remove Of Workflow Chain"""
3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675
    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 \
                       AddWorkflowToBusinessTemplate \
                       AddRemovedWorkflowChainToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       Tic \
                       InstallWithRemoveCheckedBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckWorkflowExists \
                       CheckWorkflowChainRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
3676
    sequence_list.play(self)
3677

Aurel's avatar
Aurel committed
3678
  # test of module
3679 3680
  def test_05_BusinessTemplateWithModule(self):
    """Test Business Template With Module"""
Aurel's avatar
Aurel committed
3681 3682 3683 3684 3685 3686 3687
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3688
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699
                       AddModuleToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
3700
                       RemovePortalType \
Aurel's avatar
Aurel committed
3701 3702 3703 3704 3705 3706 3707 3708 3709 3710
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3711
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3712 3713 3714
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
Aurel's avatar
Aurel committed
3715
                       CheckModulePermissions \
Aurel's avatar
Aurel committed
3716 3717 3718 3719 3720 3721 3722 3723
                       CheckModuleObjectsRemoved \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckModuleRemoved \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
3724
    sequence_list.play(self)
Aurel's avatar
Aurel committed
3725 3726

  # test of categories
3727 3728
  def test_06_BusinessTemplateWithBaseCategory(self):
    """Test Business Template With Base Category"""
Aurel's avatar
Aurel committed
3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
3747 3748
                       Tic \
                       CheckBaseCategoryRemoved \
Aurel's avatar
Aurel committed
3749 3750 3751 3752 3753 3754 3755 3756
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3757
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3758 3759
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772
                       SaveBaseCategoryUid \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckBaseCategoryExists \
                       CheckBaseCategoryUid \
Aurel's avatar
Aurel committed
3773 3774 3775 3776 3777
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
3778
    sequence_list.addSequenceString(sequence_string)
3779
    sequence_list.play(self)
Aurel's avatar
Aurel committed
3780

3781 3782
  def test_06_BusinessTemplateReInstallWithBaseCategory(self):
    """Test Business Template reinstall after removing Base Category"""
3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       RemoveBaseCategory \
                       CheckPreinstallReturnSomething \
                       '
    sequence_list.addSequenceString(sequence_string)
3806
    sequence_list.play(self)
3807

Aurel's avatar
Aurel committed
3808
  # test of actions
3809 3810
  def test_07_BusinessTemplateWithOneAction(self):
    """Test Business Template With One Action"""
Aurel's avatar
Aurel committed
3811 3812 3813
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
3814
                       CreateFirstAction \
Aurel's avatar
Aurel committed
3815 3816 3817 3818 3819
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
3820
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3839
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3840 3841
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
Aurel's avatar
Aurel committed
3842
                       CheckFirstActionExists \
Aurel's avatar
Aurel committed
3843 3844 3845 3846 3847 3848
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
3849
    sequence_list.play(self)
3850

3851 3852
  def test_07_BusinessTemplateWithEmptyAction(self):
    """Test Business Template Upgrade With Empty Action"""
3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889
    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)
3890
    sequence_list.play(self)
3891

3892 3893
  def test_08_BusinessTemplateWithTwoActions(self):
    """Test Business Template With Two Actions"""
Aurel's avatar
Aurel committed
3894 3895 3896
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
Aurel's avatar
Aurel committed
3897 3898
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
3899 3900 3901 3902
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
Aurel's avatar
Aurel committed
3903
                       AddSecondActionToBusinessTemplate \
Aurel's avatar
Aurel committed
3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       CreatePortalType \
Aurel's avatar
Aurel committed
3915
                       CreateFirstAction \
Aurel's avatar
Aurel committed
3916 3917 3918 3919 3920 3921 3922 3923
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3924
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3925
                       CheckSkinsLayers \
Aurel's avatar
Aurel committed
3926 3927
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
3928 3929 3930
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
Aurel's avatar
Aurel committed
3931
                       CheckSecondActionNotExists \
Aurel's avatar
Aurel committed
3932 3933 3934
                       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
3935
    sequence_list.play(self)
Aurel's avatar
Aurel committed
3936

3937 3938
  def test_09_BusinessTemplateWithPath(self):
    """Test Business Template With A Simple Path"""
3939
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
3940
    # a simple path
3941
    sequence_string = '\
Aurel's avatar
Aurel committed
3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965
                       CreateBaseCategory \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddBaseCategoryAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBaseCategory \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
3966
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
3967 3968 3969 3970 3971 3972 3973
                       CheckSkinsLayers \
                       CheckBaseCategoryExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckBaseCategoryRemoved \
                       '
Romain Courteaud's avatar
Romain Courteaud committed
3974
    sequence_list.addSequenceString(sequence_string)
3975
    sequence_list.play(self)
3976

3977 3978
  def test_091_BusinessTemplateDoNotUnindexObject(self):
    """Test Business Template Do Not Unindex Object At Build"""
3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000
    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)
4001
    sequence_list.play(self)
4002

4003 4004
  def test_10_BusinessTemplateWithPathAndJoker1(self):
    """Test Business Template With Path And Joker *"""
Aurel's avatar
Aurel committed
4005
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032
    # 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 \
4033
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4034 4035 4036 4037 4038 4039 4040
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
Aurel's avatar
Aurel committed
4041
                       '
Aurel's avatar
Aurel committed
4042
    sequence_list.addSequenceString(sequence_string)
4043
    sequence_list.play(self)
4044

4045 4046
  def test_101_BusinessTemplateUninstallWithPathAndJoker1Removed(self):
    """Test Business Template Uninstall With Path And Joker * Removed"""
4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085
    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)
4086
    sequence_list.play(self)
4087

4088 4089
  def test_11_BusinessTemplateWithPathAndJoker2(self):
    """Test Business Template With Path And Joker **"""
4090
    sequence_list = SequenceList()
Aurel's avatar
Aurel committed
4091
    # path with subobject recursively
4092
    sequence_string = '\
Aurel's avatar
Aurel committed
4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118
                       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 \
4119
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4120 4121 4122 4123 4124 4125 4126 4127 4128
                       CheckSkinsLayers \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckCategoriesRemoved \
                       RemoveBaseCategory \
                       '
4129
    sequence_list.addSequenceString(sequence_string)
4130 4131 4132 4133
    sequence_list.play(self)

  def test_111_BusinessTemplateWithContentTypeRegistry(self):
    """Test Business Template With Content Type Registry As Path
4134

4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178
      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.
    """
    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)
4179
    sequence_list.play(self)
4180

4181 4182
  def test_12_BusinessTemplateWithCatalogMethod(self):
    """Test Business Template With Catalog Method, Related Key, Result Key And Table"""
Aurel's avatar
Aurel committed
4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
4204 4205
                       Tic \
                       CheckKeysAndTableRemoved \
Aurel's avatar
Aurel committed
4206 4207 4208 4209 4210 4211 4212 4213
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4214
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4215 4216 4217 4218 4219 4220 4221 4222 4223 4224
                       CheckSkinsLayers \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckKeysAndTableRemoved \
                       CheckCatalogMethodRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4225
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4226

4227 4228
  def test_121_BusinessTemplateWithUpdateOfCatalogMethod(self):
    """Test Business Template Update With Catalog Method, Related Key, Result Key And Table"""
4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284
    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 \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       RemoveCatalogMethod \
                       CreateUpdateCatalogMethod \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveCatalogMethod \
                       CreateCatalogMethod \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
Aurel's avatar
Aurel committed
4285 4286
                       CheckPreinstallReturnSomething \
                       CheckCatalogPreinstallReturnCatalogMethod \
4287
                       Tic \
Aurel's avatar
Aurel committed
4288
                       InstallWithoutForceBusinessTemplate \
4289
                       CheckFolderReindexActivityPresence \
4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckSkinsLayers \
                       CheckUpdatedCatalogMethodExists \
                       CheckKeysAndTableExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckKeysAndTableRemoved \
                       CheckCatalogMethodRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4303
    sequence_list.play(self)
4304

4305 4306
  def test_122_BusinessTemplateWithRemoveCatalogMethod(self):
    """Test Business Template remove a Catalog Method"""
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 4346 4347 4348 4349
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       SaveBusinessTemplate \
                       CheckNotInstalledInstallationState \
                       RemoveCatalogMethod \
                       RemoveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckBuiltBuildingState \
                       CheckInstalledInstallationState \
                       CheckCatalogMethodExists \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       RemoveCatalogMethodToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       SaveBusinessTemplate \
                       ImportBusinessTemplate \
                       Tic \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckInstalledInstallationState \
                       Tic \
                       CheckCatalogMethodRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4350
    sequence_list.play(self)
4351

4352 4353
  def test_13_BusinessTemplateWithRole(self):
    """Test Business Template With Role"""
Aurel's avatar
Aurel committed
4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379
    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 \
4380
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4381 4382 4383 4384 4385 4386 4387 4388
                       CheckSkinsLayers \
                       CheckRoleExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckRoleRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4389
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4390

4391 4392
  def test_14_BusinessTemplateWithLocalRoles(self):
    """Test Business Template With Local Roles"""
Aurel's avatar
Aurel committed
4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateLocalRoles \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddLocalRolesToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveLocalRoles \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
4413
                       Tic \
Aurel's avatar
Aurel committed
4414 4415
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
4416
                       Tic \
Aurel's avatar
Aurel committed
4417 4418
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
4419
                       CheckModuleLocalRolesInCatalogBeforeUpdate \
Aurel's avatar
Aurel committed
4420 4421 4422 4423
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4424
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4425 4426
                       CheckSkinsLayers \
                       CheckLocalRolesExists \
4427
                       CheckModuleLocalRolesInCatalogAfterUpdate \
Aurel's avatar
Aurel committed
4428 4429 4430 4431 4432 4433 4434 4435
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckLocalRolesRemoved \
                       RemoveModule \
                       RemovePortalType \
                       '
    sequence_list.addSequenceString(sequence_string)
4436
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4437

4438 4439
  def test_15_BusinessTemplateWithPropertySheet(self):
    """Test Business Template With Property Sheet"""
Aurel's avatar
Aurel committed
4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465
    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 \
4466
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4467 4468 4469 4470 4471 4472 4473 4474
                       CheckSkinsLayers \
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPropertySheetRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4475
    sequence_list.play(self)
4476

4477 4478
  def test_151_BusinessTemplateWithPropertySheetMigration(self):
    """Test Business Template With Property Sheet Migration"""
4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514
    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 \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckPropertySheetMigration \
                       CheckPropertySheetRemoved \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckMigratedPropertySheetRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
4515
    sequence_list.play(self)
4516

4517 4518
  def test_155_BusinessTemplateUpdateWithPropertySheet(self):
    """Test Business Template With Property Sheet"""
4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544
    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 \
4545
                       CheckNoTrashBin \
4546 4547
                       CheckSkinsLayers \
                       CheckPropertySheetExists \
4548
                       RemovePropertySheetFromZODB \
4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575
                       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
4576
                       CheckWorkflowChainRemoved \
4577 4578
                       '
    sequence_list.addSequenceString(sequence_string)
4579
    sequence_list.play(self)
4580

4581 4582
  def test_16_BusinessTemplateWithAllItems(self):
    """Test Business Template With All Items"""
Aurel's avatar
Aurel committed
4583 4584 4585 4586 4587 4588 4589 4590 4591
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
4592 4593
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
4594 4595 4596
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
4597
                       CreateLocalRoles \
Aurel's avatar
Aurel committed
4598 4599 4600 4601
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
4602
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
4603 4604 4605 4606 4607
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4608
                       AddWorkflowChainToBusinessTemplate \
Aurel's avatar
Aurel committed
4609 4610 4611
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
4612
                       AddLocalRolesToBusinessTemplate \
Aurel's avatar
Aurel committed
4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
4624
                       RemovePortalType \
Aurel's avatar
Aurel committed
4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4642
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4643 4644 4645 4646 4647 4648 4649 4650
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
4651 4652
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
4653 4654 4655
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
4656
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672
                       CheckPropertySheetExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckPortalTypeRemoved \
                       CheckModuleRemoved \
                       CheckSkinFolderRemoved \
                       CheckBaseCategoryRemoved \
                       CheckWorkflowRemoved \
                       CheckCatalogMethodRemoved \
                       CheckKeysAndTableRemoved \
                       CheckRoleRemoved \
                       CheckPropertySheetRemoved \
                       CheckSkinsLayers \
                       '
    sequence_list.addSequenceString(sequence_string)
4673
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4674

4675 4676
  def test_17_SubobjectsAfterUpgradOfBusinessTemplate(self):
    """Test Upgrade Of Business Template Keeps Subobjects"""
Aurel's avatar
Aurel committed
4677 4678 4679 4680 4681 4682 4683 4684 4685
    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
4686
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699
                       AddModuleToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
                       RemoveBaseCategory \
4700
                       RemovePortalType \
Aurel's avatar
Aurel committed
4701 4702 4703 4704 4705 4706 4707 4708 4709 4710
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4711
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
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 4741 4742 4743 4744
                       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
4745
                       '
Aurel's avatar
Aurel committed
4746
    sequence_list.addSequenceString(sequence_string)
4747
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4748

4749 4750
  def test_18_upgradeBusinessTemplateWithAllItems(self):
    """Test Upgrade Business Template With All Items"""
Aurel's avatar
Aurel committed
4751 4752 4753 4754 4755 4756 4757 4758 4759 4760
    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
4761 4762
                       CreateFirstAction \
                       CreateSecondAction \
Aurel's avatar
Aurel committed
4763 4764 4765
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
4766
                       CreateLocalRoles \
Aurel's avatar
Aurel committed
4767 4768 4769 4770
                       CreatePropertySheet \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
4771
                       FillPortalTypesFields \
Aurel's avatar
Aurel committed
4772 4773 4774 4775 4776
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4777
                       AddWorkflowChainToBusinessTemplate \
Aurel's avatar
Aurel committed
4778 4779 4780
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
4781
                       AddLocalRolesToBusinessTemplate \
Aurel's avatar
Aurel committed
4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792
                       AddPropertySheetToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveModule \
4793
                       RemovePortalType \
Aurel's avatar
Aurel committed
4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
4811
                       CheckNoTrashBin \
Aurel's avatar
Aurel committed
4812 4813 4814 4815 4816 4817 4818 4819
                       CheckSkinsLayers \
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
4820
                       CheckWorkflowChainExists \
Aurel's avatar
Aurel committed
4821 4822
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
4823 4824 4825
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
4826
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837
                       CheckPropertySheetExists \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
4838
                       CheckWorkflowBackup \
Aurel's avatar
Aurel committed
4839 4840 4841 4842 4843 4844 4845
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
4846
                       CheckWorkflowChainExists \
Aurel's avatar
Aurel committed
4847 4848
                       CheckFirstActionExists \
                       CheckSecondActionExists \
Aurel's avatar
Aurel committed
4849 4850 4851
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
4852
                       CheckLocalRolesExists \
Aurel's avatar
Aurel committed
4853 4854
                       CheckPropertySheetExists \
                       CheckSkinsLayers \
4855
                       RemoveModule \
4856
                       RemovePortalType \
4857 4858 4859 4860 4861 4862
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
4863
                       RemovePropertySheetFromZODB \
4864 4865
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
Aurel's avatar
Aurel committed
4866 4867
                       '
    sequence_list.addSequenceString(sequence_string)
4868
    sequence_list.play(self)
4869

Aurel's avatar
Aurel committed
4870
  # test specific to erp5_core
4871 4872
  def test_19_checkUpdateBusinessTemplateWorkflow(self):
    """Test Check Update of Business Template Workflows is working"""
Aurel's avatar
Aurel committed
4873 4874
    sequence_list = SequenceList()
    sequence_string = '\
4875 4876 4877 4878 4879 4880 4881
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
4882 4883
                       CreateFirstAction \
                       CreateSecondAction \
4884 4885 4886
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
4887
                       CreateLocalRoles \
4888
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
4889 4890
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
4891
                       ClearBusinessTemplateField \
4892
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
4893
                       FillPortalTypesFields \
4894 4895 4896 4897 4898
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4899
                       AddWorkflowChainToBusinessTemplate \
4900 4901 4902
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
4903
                       AddLocalRolesToBusinessTemplate \
4904
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckTrashBin \
                       CheckSkinsLayers \
4925 4926 4927 4928 4929 4930 4931
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
4932 4933
                       CheckFirstActionExists \
                       CheckSecondActionExists \
4934 4935 4936
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
4937
                       CheckLocalRolesExists \
4938 4939
                       CheckPropertySheetExists \
                       RemoveModule \
4940
                       RemovePortalType \
4941 4942 4943 4944 4945 4946
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
4947
                       RemovePropertySheetFromZODB \
Aurel's avatar
Aurel committed
4948 4949
                       '
    sequence_list.addSequenceString(sequence_string)
4950
    sequence_list.play(self)
Aurel's avatar
Aurel committed
4951

4952 4953
  def test_20_checkUpdateTool(self):
    """Test Check Update of Tool is working"""
Aurel's avatar
Aurel committed
4954 4955
    sequence_list = SequenceList()
    sequence_string = '\
4956 4957 4958 4959 4960 4961 4962
                       CreatePortalType \
                       CreateModuleAndObjects \
                       CreateSkinFolder \
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateWorkflow \
Aurel's avatar
Aurel committed
4963 4964
                       CreateFirstAction \
                       CreateSecondAction \
4965 4966 4967
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateRole \
Aurel's avatar
Aurel committed
4968
                       CreateLocalRoles \
4969
                       CreatePropertySheet \
Aurel's avatar
Aurel committed
4970 4971
                       CopyCoreBusinessTemplate \
                       UseCopyCoreBusinessTemplate  \
4972
                       ClearBusinessTemplateField \
Aurel's avatar
Aurel committed
4973
                       SetUpdateToolFlagInBusinessTemplate \
4974
                       AddPortalTypeToBusinessTemplate \
Aurel's avatar
Aurel committed
4975
                       FillPortalTypesFields \
4976 4977 4978 4979 4980
                       AddModuleToBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       AddWorkflowToBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
4981
                       AddWorkflowChainToBusinessTemplate \
4982 4983 4984
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       AddRoleToBusinessTemplate \
Aurel's avatar
Aurel committed
4985
                       AddLocalRolesToBusinessTemplate \
4986
                       AddPropertySheetToBusinessTemplate \
Aurel's avatar
Aurel committed
4987 4988 4989 4990 4991 4992 4993 4994 4995
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
4996
                       RemoveModule \
4997
                       RemovePortalType \
4998 4999 5000 5001 5002 5003 5004 5005
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
                       RemovePropertySheet \
                       RemoveBusinessTemplate \
Aurel's avatar
Aurel committed
5006
                       RemoveAllTrashBins \
5007
                       RemoveSimulationTool \
Aurel's avatar
Aurel committed
5008 5009 5010 5011 5012 5013 5014 5015
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
5016
                       CheckSimulationToolExists \
Aurel's avatar
Aurel committed
5017
                       CheckSkinsLayers \
5018 5019 5020 5021 5022 5023 5024
                       CheckPortalTypeExists \
                       CheckModuleExists \
                       CheckSkinFolderExists \
                       CheckBaseCategoryExists \
                       CheckCategoriesExists \
                       CheckSubCategoriesExists \
                       CheckWorkflowExists \
Aurel's avatar
Aurel committed
5025 5026
                       CheckFirstActionExists \
                       CheckSecondActionExists \
5027 5028 5029
                       CheckCatalogMethodExists \
                       CheckKeysAndTableExists \
                       CheckRoleExists \
Aurel's avatar
Aurel committed
5030
                       CheckLocalRolesExists \
5031 5032
                       CheckPropertySheetExists \
                       RemoveModule \
5033
                       RemovePortalType \
5034 5035 5036 5037 5038 5039
                       RemoveSkinFolder \
                       RemoveBaseCategory \
                       RemoveWorkflow \
                       RemoveCatalogMethod \
                       RemoveKeysAndTable \
                       RemoveRole \
5040
                       RemovePropertySheetFromZODB \
Aurel's avatar
Aurel committed
5041 5042
                       '
    sequence_list.addSequenceString(sequence_string)
5043
    sequence_list.play(self)
Aurel's avatar
Aurel committed
5044

5045 5046
  def test_21_CategoryIncludeSubobjects(self):
    """Test Category includes subobjects"""
5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddBaseCategoryToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSubobjectsNotIncluded \
                       '
    sequence_list.addSequenceString(sequence_string)
5061
    sequence_list.play(self)
5062

5063
  # test of portal types
5064 5065
  def test_22_RevisionNumberIsIncremented(self):
    """Test is revision number is incremented with the bt is built"""
5066 5067
    sequence_list = SequenceList()
    sequence_string = '\
5068
                       CreatePortalType \
5069
                       CreateNewBusinessTemplate \
5070 5071
                       UseExportBusinessTemplate \
                       CheckInitialRevision \
5072 5073
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
5074 5075 5076
                       stepCheckFirstRevision \
                       BuildBusinessTemplate \
                       stepCheckSecondRevision \
5077
                       RemoveBusinessTemplate \
5078
                       RemovePortalType \
5079 5080
                       '
    sequence_list.addSequenceString(sequence_string)
5081
    sequence_list.play(self)
Aurel's avatar
Aurel committed
5082

5083 5084
  def test_23_CheckNoDependencies(self):
    """Test if a new Business Template has no dependencies"""
5085 5086
    sequence_list = SequenceList()
    sequence_string = '\
5087
                       CreatePortalType \
5088
                       CreateNewBusinessTemplate \
5089
                       UseExportBusinessTemplate \
5090 5091
                       CheckNoMissingDependencies \
                       RemoveBusinessTemplate \
5092
                       RemovePortalType \
5093 5094
                       '
    sequence_list.addSequenceString(sequence_string)
5095
    sequence_list.play(self)
5096

5097 5098
  def test_24_CheckMissingDependency(self):
    """Test if a exception is raised when a dependency is missing"""
5099 5100
    sequence_list = SequenceList()
    sequence_string = '\
5101
                       CreatePortalType \
5102
                       CreateNewBusinessTemplate \
5103
                       UseExportBusinessTemplate \
5104 5105 5106
                       AddDependency \
                       CheckMissingDependencies \
                       RemoveBusinessTemplate \
5107
                       RemovePortalType \
5108 5109
                       '
    sequence_list.addSequenceString(sequence_string)
5110
    sequence_list.play(self)
5111

5112 5113
  def test_25_CheckNoMissingDependency(self):
    """Test if the dependency problem is fixed when the dependency is installed"""
5114 5115
    sequence_list = SequenceList()
    sequence_string = '\
5116
                       CreatePortalType \
5117
                       CreateNewBusinessTemplate \
5118
                       UseExportBusinessTemplate \
5119 5120 5121 5122 5123 5124
                       AddDependency \
                       CheckMissingDependencies \
                       CreateDependencyBusinessTemplate \
                       CheckMissingDependencies \
                       UseDependencyBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
5125 5126 5127 5128 5129 5130
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
5131 5132 5133
                       CheckInstalledInstallationState \
                       UseExportBusinessTemplate \
                       CheckNoMissingDependencies \
Christophe Dumez's avatar
Christophe Dumez committed
5134
                       UseImportBusinessTemplate \
5135 5136 5137
                       UninstallBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckMissingDependencies \
Christophe Dumez's avatar
Christophe Dumez committed
5138
                       UseImportBusinessTemplate \
5139 5140
                       RemoveBusinessTemplate \
                       UseExportBusinessTemplate \
5141 5142 5143
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
5144
    sequence_list.play(self)
5145

5146
  # test of skins
5147 5148
  def test_26_ImportWithDoubleSlashes(self):
    """Test Importing Business Template With Double Slashes"""
5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175
    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 \
5176
                       CheckNoTrashBin \
5177 5178 5179 5180 5181 5182 5183 5184
                       CheckSkinsLayers \
                       CheckSkinFolderExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckSkinFolderRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
5185
    sequence_list.play(self)
5186

5187 5188
  def test_27_CheckInstallWithBackup(self):
    """Test if backup works during installation of a bt with subfolder in skin folder"""
5189 5190
    sequence_list = SequenceList()
    sequence_string = '\
5191
                       CreatePortalType \
5192 5193 5194 5195 5196 5197 5198 5199 5200
                       CreateSkinFolder \
                       CheckSkinFolderExists \
                       CreateSkinSubFolder \
                       CheckSkinSubFolderExists \
                       CreateNewObjectInSkinSubFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
5201 5202 5203 5204 5205 5206
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
5207 5208 5209 5210
                       UninstallBusinessTemplate \
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
5211
    sequence_list.play(self)
5212

5213 5214
  def test_28_CheckBuildWithUnexistingPath(self):
    """Test if build fails when one of the paths does not exist"""
5215 5216
    sequence_list = SequenceList()
    sequence_string = '\
5217
                       CreatePortalType \
5218 5219 5220 5221 5222
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPathToBusinessTemplate \
                       BuildBusinessTemplateFail \
                       RemoveBusinessTemplate \
5223
                       RemovePortalType \
5224 5225
                       '
    sequence_list.addSequenceString(sequence_string)
5226
    sequence_list.play(self)
5227

5228 5229
  def test_29_CheckUninstallRemovedSkinFolder(self):
    """Test if uninstall works even when the skin folder has already been removed from the site"""
5230 5231
    sequence_list = SequenceList()
    sequence_string = '\
5232
                       CreatePortalType \
5233 5234 5235 5236 5237 5238
                       CreateSkinFolder \
                       CheckSkinFolderExists \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
Christophe Dumez's avatar
Christophe Dumez committed
5239 5240
                       SaveBusinessTemplate \
                       RemoveBusinessTemplate \
5241
                       RemovePortalType \
Christophe Dumez's avatar
Christophe Dumez committed
5242 5243 5244
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
5245 5246 5247 5248 5249
                       RemoveSkinFolder \
                       UninstallBusinessTemplate \
                       RemoveBusinessTemplate \
                       '
    sequence_list.addSequenceString(sequence_string)
5250 5251 5252 5253
    sequence_list.play(self)

  def test_30_CheckInstalledCatalogProperties(self):
    """Test if installing some new catalog properties overwrites existing ones"""
5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateCatalogMethod \
                       CreateKeysAndTable \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddCatalogMethodToBusinessTemplate \
                       AddKeysAndTableToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       ModifyCatalogConfiguration \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckCatalogConfigurationKept \
                       UninstallBusinessTemplate \
                       CheckCatalogConfigurationKept \
5272
                       RemoveCatalogLocalConfiguration \
5273 5274
                       '
    sequence_list.addSequenceString(sequence_string)
5275
    sequence_list.play(self)
5276

5277 5278
  def test_31_BusinessTemplateWithCatalogMethod(self):
    """Test that we keep local changes if we specify a list of objects to update"""
5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310
    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 \
5311
                       RemoveKeysAndTable \
5312 5313
                       '
    sequence_list.addSequenceString(sequence_string)
5314
    sequence_list.play(self)
5315

5316 5317
  def test_32_BusinessTemplateWithDuplicatedPortalTypes(self):
    """Test Business Template With Duplicated Portal Types"""
5318 5319 5320 5321 5322
    sequence_list = SequenceList()
    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateSecondAction \
5323
                       CreateWorkflow \
5324 5325 5326
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
5327 5328
                       AddWorkflowToBusinessTemplate \
                       AddWorkflowChainToBusinessTemplate \
5329 5330 5331 5332 5333
                       AddSecondActionToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemovePortalType \
5334
                       RemoveWorkflow \
5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359
                       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)
5360
    sequence_list.play(self)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5361

5362 5363
  def test_33_BusinessTemplateWithNewSkinSelection(self):
    """Test Business Template With New Skin Selection"""
5364 5365 5366
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5367
                       SetSkinFolderRegisteredSelections \
5368 5369 5370
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5371
                       AddRegisteredSelectionToBusinessTemplate \
5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CheckSkinSelectionAdded \
                       '
    sequence_list.addSequenceString(sequence_string)
5384
    sequence_list.play(self)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5385

5386 5387
  def test_34_UpgradeForm(self):
    """Test Upgrade Form"""
5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       CreateNewForm \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveForm \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
5402
                       CheckFolderReindexActivityPresence \
5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415
                       Tic \
                       \
                       CheckFormGroups \
                       AddFormField \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveFormField \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
5416
                       Tic \
5417
                       InstallWithoutForceBusinessTemplate \
5418
                       CheckFolderReindexActivityPresence \
5419 5420 5421 5422 5423
                       Tic \
                       \
                       CheckFormGroups \
                       '
    sequence_list.addSequenceString(sequence_string)
5424
    sequence_list.play(self)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5425

5426 5427
  def test_34_UpgradeFormAttribute(self):
    """Test Upgrade Form"""
5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
                       CreateNewForm \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveForm \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormGroups \
                       ModifyFormTitle \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RevertFormTitle \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormTitle \
                       CheckFormGroups \
                       '
    sequence_list.addSequenceString(sequence_string)
5462 5463 5464 5465
    sequence_list.play(self)

  def test_34_RemoveForm(self):
    """Test Upgrade Form
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5466

5467
    - Add a form into the skin folders of erp5_geek and erp5_nerd
5468
    - Remove the form from erp5_geek
5469 5470 5471
    - Check that the form is removed from erp5_geek
    - Check that the form is not removed from erp5_nerd
    - Check that the title field is not removed from erp5_nerd
5472 5473 5474 5475
    """
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateSkinFolder \
5476 5477
                       CreateAnotherSkinFolder \
                       CreateNewFormIntoErp5Nerd \
5478 5479 5480 5481
                       CreateNewForm \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
5482
                       AddAnotherSkinFolderToBusinessTemplate \
5483 5484 5485 5486 5487 5488 5489 5490 5491
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormGroups \
5492
                       \
5493 5494 5495 5496
                       RemoveForm \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
5497
                       AddAnotherSkinFolderToBusinessTemplate \
5498 5499
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
5500
                       \
5501 5502
                       CreateNewForm \
                       \
5503
                       CheckFieldTitleIsNotRemovedFromErp5Nerd \
5504 5505 5506 5507 5508 5509 5510
                       \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckFormIsRemoved \
5511 5512
                       CheckFormIsNotRemovedFromErp5Nerd \
                       CheckFieldTitleIsNotRemovedFromErp5Nerd \
5513
                       CheckTrashBin \
5514 5515
                       '
    sequence_list.addSequenceString(sequence_string)
5516
    sequence_list.play(self)
5517

5518
  def test_checkDependencies(self):
5519
    from Products.ERP5.Document.BusinessTemplate import \
5520 5521 5522 5523 5524 5525 5526 5527
          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())
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5528

5529 5530
    bt5.setDependencyList(['erp5_core (> %s)' % erp5_core_version])
    self.assertRaises(BusinessTemplateMissingDependency, bt5.checkDependencies)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5531

5532 5533
    bt5.setDependencyList(['not_exists (= 1.0)'])
    self.assertRaises(BusinessTemplateMissingDependency, bt5.checkDependencies)
Kazuhiko Shiozaki's avatar
Kazuhiko Shiozaki committed
5534

5535 5536
  def test_34_RemovePartialWorkflowChain(self):
    """Test Remove Chain"""
5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591
    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)
5592
    sequence_list.play(self)
5593

5594 5595
  def test_35_UpdatePartialWorkflowChain(self):
    """Test Update Workflow Chain"""
5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660
    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)
5661
    sequence_list.play(self)
5662

5663 5664 5665 5666
  def test_35a_UpdatePartialWorkflowChainWithRemove(self):
    """Check that chains are correctly removed during update
    
    When previous business template defined that object is associated
Łukasz Nowak's avatar
Łukasz Nowak committed
5667 5668 5669
    with workflows A, B and that new one says that only A association
    is required check that after installing only A will be on workflow
    chains."""
5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699
    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 \
                       \
5700 5701 5702
                       CopyBusinessTemplate \
                       Tic \
                       \
5703 5704
                       CreateCustomWorkflow \
                       CheckCustomWorkflowChain \
Łukasz Nowak's avatar
Łukasz Nowak committed
5705 5706
                       AppendWorkflowToBusinessTemplate \
                       AppendWorkflowChainToBusinessTemplate \
5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveWorkflow \
                       CheckOriginalWorkflowChain \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       \
                       CheckCustomWorkflowChain \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       \
                       RemoveWorkflowFromBusinessTemplate \
                       RemoveWorkflowChainFromBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       SaveBusinessTemplate \
                       ImportBusinessTemplate \
                       Tic \
                       UseImportBusinessTemplate \
5731
                       InstallBusinessTemplate \
5732
                       Tic \
Łukasz Nowak's avatar
Łukasz Nowak committed
5733
                       CheckOriginalWorkflowChain \
5734 5735 5736 5737 5738
                       CheckWorkflowChainExists \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

5739 5740
  def test_36_CheckPortalTypeRoles(self):
    """Test Portal Type Roles"""
5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776
    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)
5777
    sequence_list.play(self)
5778

5779 5780
  def test_37_UpdatePortalType(self):
    """Test Update Portal Type"""
5781
    sequence_list = SequenceList()
5782

5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802
    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemovePortalType \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckFirstActionExists \
                       \
                       CreateSecondAction \
                       CheckSecondActionExists \
5803 5804
                       CreatePortalTypeRole \
                       CheckPortalTypeRoleExists \
5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822
                       \
                       ModifyPortalType \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       EditBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       SaveBusinessTemplate \
                       \
                       UnmodifyPortalType \
                       \
                       ImportBusinessTemplate \
                       Tic \
                       UseImportBusinessTemplate \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
5823
                       CheckModifiedPortalTypeExists \
5824 5825
                       CheckFirstActionExists \
                       CheckSecondActionExists \
5826
                       CheckPortalTypeRoleExists \
5827 5828
                       '
    sequence_list.addSequenceString(sequence_string)
5829
    sequence_list.play(self)
5830

5831 5832
  def test_38_CheckReinstallation(self):
    """Test Reinstallation"""
5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845
    sequence_list = SequenceList()

    sequence_string = '\
                       CreatePortalType \
                       CreateFirstAction \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddPortalTypeToBusinessTemplate \
                       FillPortalTypesFields \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       InstallCurrentBusinessTemplate Tic \
                       Tic \
Julien Muchembled's avatar
Julien Muchembled committed
5846
                       RemoveFirstAction \
Nicolas Delaby's avatar
Nicolas Delaby committed
5847
                       CheckBeforeReinstall \
5848
                       ReinstallBusinessTemplate Tic \
Nicolas Delaby's avatar
Nicolas Delaby committed
5849 5850 5851
                       \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
5852
                       AddCustomSkinFolderToBusinessTemplate \
Nicolas Delaby's avatar
Nicolas Delaby committed
5853 5854 5855 5856 5857 5858
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       InstallCurrentBusinessTemplate Tic \
                       CreateFakeZODBScript \
                       ReinstallBusinessTemplate \
                       Tic \
5859
                       CheckFakeScriptIsDeleted \
5860 5861
                       '
    sequence_list.addSequenceString(sequence_string)
5862
    sequence_list.play(self)
5863

5864 5865
  def test_39_CheckSiteProperties(self):
    """Test Site Properties"""
5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901
    sequence_list = SequenceList()
    sequence_string = '\
                       SetOldSitePropertyValue \
                       CreateSiteProperty \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddSitePropertyToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       SetNewSitePropertyValue \
                       ModifySiteProperty \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       SetOldSitePropertyValue \
                       CheckSiteProperty \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       SetOldSitePropertyValue \
                       CheckSitePropertyRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
5902
    sequence_list.play(self)
5903

5904
  # test of uid
5905 5906 5907
  def test_40_BusinessTemplateUidOfCategoriesUnchanged(self):
    """Test that the uids of categories are unchanged during their reinstall

5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942
      Add sub categories with the title 'toto' and save their uid in a dict
      Create business template with the sub categories in path_template_list
      The sub categories title are changed in 'foo'
      Install business template
      Check the old sub categories with' toto' as title
      And check if the uid of sub categories is unchanged
    """
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateBaseCategory \
                       CreateCategories \
                       CreateSubCategories \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       AddSubCategoriesAsPathToBusinessTemplate \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckSubCategoriesExists \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       ModifySubCategories \
                       Tic \
                       InstallBusinessTemplate \
                       Tic \
                       CheckSubCategoriesExists \
                       CheckUidSubCategories \
                       UninstallBusinessTemplate \
                      '
    sequence_list.addSequenceString(sequence_string)
5943
    sequence_list.play(self)
5944

5945 5946
  def test_158_BusinessTemplateSkinSelectionRemove(self):
    """Test Business Template Uninstall With Skin Selection"""
5947 5948
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5949
                       SetSkinFolderRegisteredSelections \
5950 5951 5952
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5953
                       AddRegisteredSelectionToBusinessTemplate \
5954 5955 5956 5957 5958 5959 5960 5961
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckSkinSelectionAdded \
5962 5963 5964 5965
                       UninstallBusinessTemplate \
                       CheckSkinSelectionRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
5966
    sequence_list.play(self)
5967

5968 5969
  def test_158_BusinessTemplateSkinSelectionRemoveOnlyIfUnused(self):
    """Test Business Template Uninstall With an used Skin Selection"""
5970 5971 5972 5973
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
                       CreateStaticSkinFolder \
                       CreateSkinSelection \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5974 5975
                       SetSkinFolderRegisteredSelections \
                       SetStaticSkinFolderRegisteredSelections \
5976 5977 5978
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5979
                       AddRegisteredSelectionToBusinessTemplate \
5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckStaticSkinSelection \
                       UninstallBusinessTemplate \
                       CheckSkinSelectionNotRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
5992
    sequence_list.play(self)
5993

5994 5995
  def test_159_BusinessTemplateNotRegisterSkin(self):
    """Test Business Template will not register existing Skin"""
5996 5997
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
5998
                       SetSkinFolderRegisteredSelections \
5999 6000 6001
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
Arnaud Fontaine's avatar
Arnaud Fontaine committed
6002
                       AddRegisteredSelectionToBusinessTemplate \
6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       UserDisableSkinSelectionRegistration \
                       InstallBusinessTemplate \
                       Tic \
                       CheckSkinSelectionRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
6014
    sequence_list.play(self)
6015

6016 6017
  def test_160_BusinessTemplateChangeOnlySelectedSkin(self):
    """Test Business Template will change only selected skins"""
6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       UserSelectSkinToBeChanged \
                       InstallBusinessTemplate \
                       Tic \
                       CheckUserSelectedSkinToBeChanged \
                       '
    sequence_list.addSequenceString(sequence_string)
6034
    sequence_list.play(self)
6035

6036 6037
  def test_161_BusinessTemplateCheckSkinPriorityOrderingEnabled(self):
    """Test Business Template will reorder skins path in Skin"""
6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
                       SetBusinessTemplateSkinFolderPriority \
                       SetExistingSkinFolderPriority \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       InstallBusinessTemplate \
                       Tic \
                       CheckSkinFolderPriorityOn \
                       '
    sequence_list.addSequenceString(sequence_string)
6055
    sequence_list.play(self)
6056

6057 6058
  def test_162_BusinessTemplateCheckSkinPriorityOrderingDisabled(self):
    """Test Business Template will not reorder skins path in Skin"""
6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070
    sequence_list = SequenceList()
    sequence_string = 'CreateSkinFolder \
                       SetBusinessTemplateSkinFolderPriority \
                       SetExistingSkinFolderPriority \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddSkinFolderToBusinessTemplate \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveSkinFolder \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
6071 6072 6073 6074 6075 6076 6077
                       UserDisableSkinFolderPriority \
                       InstallBusinessTemplate \
                       Tic \
                       CheckSkinFolderPriorityOff \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
6078

6079 6080
  def test_163_UpdateSkinFolderWithRegisteredSkinSelection(self):
    """Test Update Skin Folder"""
6081
    sequence_list = SequenceList()
6082 6083
    sequence_list.addSequenceString("""
      CreateSkinFolder
Arnaud Fontaine's avatar
Arnaud Fontaine committed
6084
      SetSkinFolderRegisteredSelections
6085 6086 6087
      CreateNewBusinessTemplate
      UseExportBusinessTemplate
      AddSkinFolderToBusinessTemplate
Arnaud Fontaine's avatar
Arnaud Fontaine committed
6088
      AddRegisteredSelectionToBusinessTemplate
6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120
      BuildBusinessTemplate
      SaveBusinessTemplate
      RemoveSkinFolder
      RemoveBusinessTemplate
      RemoveAllTrashBins

      ImportBusinessTemplate
      UseImportBusinessTemplate
      InstallBusinessTemplate
      Tic
      CheckSkinSelectionAdded

      ModifySkinFolder

      CopyBusinessTemplate
      Tic
      EditBusinessTemplate
      BuildBusinessTemplate
      CheckBuiltBuildingState
      SaveBusinessTemplate

      UnmodifySkinFolder

      ImportBusinessTemplate
      Tic
      UseImportBusinessTemplate
      InstallWithoutForceBusinessTemplate
      Tic

      CheckModifiedSkinFolderExists
      CheckSkinSelectionAdded

Arnaud Fontaine's avatar
Arnaud Fontaine committed
6121
      SetSkinFolderRegisteredSelections2
6122
      CopyBusinessTemplate
Arnaud Fontaine's avatar
Arnaud Fontaine committed
6123
      EditRegisteredSelectionToBusinessTemplate
6124 6125 6126 6127
      BuildBusinessTemplate
      InstallCurrentBusinessTemplate
      Tic
    """)
6128
    sequence_list.play(self)
6129

6130
  @expectedFailure
6131 6132
  def test_164_checkCopyBuild(self):
    """Test Check basic copy and build is working"""
Yusuke Muraoka's avatar
Yusuke Muraoka committed
6133
    sequence_list = SequenceList()
6134 6135 6136 6137 6138 6139 6140
    sequence_list.addSequenceString("""
      UseCoreBusinessTemplate
      CopyCoreBusinessTemplate
      BuildCopyCoreBusinessTemplate
      CheckOriginalAndCopyBusinessTemplate
      Tic
    """)
6141
    sequence_list.play(self)
Yusuke Muraoka's avatar
Yusuke Muraoka committed
6142

6143 6144
  def test_165_checkCopyBuildInstall(self):
    """Test Check basic copy, build and installation is working"""
Yusuke Muraoka's avatar
Yusuke Muraoka committed
6145
    sequence_list = SequenceList()
6146 6147 6148 6149 6150 6151 6152
    sequence_list.addSequenceString("""
      UseCoreBusinessTemplate
      CopyCoreBusinessTemplate
      BuildCopyCoreBusinessTemplate
      InstallCopyCoreBusinessTemplate
      Tic
    """)
6153
    sequence_list.play(self)
Yusuke Muraoka's avatar
Yusuke Muraoka committed
6154

6155
  def test_167_InstanceAndRelatedClassDefinedInSameBT(self):
6156 6157 6158
    # This test does too much since we don't modify objects anymore during
    # download. Objects are cleaned up during installation, which does not
    # require any specific action about garbage collection or pickle cache.
6159
    from Products.ERP5.Document.BusinessTemplate import BaseTemplateItem
6160
    portal = self.portal
6161
    BaseTemplateItem_removeProperties = BaseTemplateItem.removeProperties
6162
    object_id_list = 'old_file', 'some_file'
6163
    marker_list = []
6164
    def removeProperties(self, obj, export):
6165
      # Check it works if the object is modified during install.
6166 6167
      if obj.id in object_id_list:
        obj.int_index = marker_list.pop()
6168 6169 6170 6171 6172
      return obj
    SimpleItem_getCopy = SimpleItem._getCopy
    try:
      BaseTemplateItem.removeProperties = removeProperties
      SimpleItem._getCopy = lambda *args: self.fail()
6173
      template_tool = portal.portal_templates
6174
      bt_path = os.path.join(os.path.dirname(__file__), 'test_data',
6175
                             'test_167_InstanceAndRelatedClassDefinedInSameBT')
6176
      # create a previously existing instance of the overriden document type
6177
      File = portal.portal_types.getPortalTypeClass('File')
6178
      portal._setObject('another_file', File('another_file'))
6179
      self.tic()
6180 6181
      # logged errors could keep a reference to a traceback having a reference
      # to 'another_file' object
6182
      self.logged = []
6183
      # check its class has not yet been overriden
6184
      self.assertFalse(getattr(portal.another_file, 'isClassOverriden', False))
6185
      for i in (0, 1):
6186
        marker_list += [i] * len(object_id_list)
6187
        gc.disable()
6188
        bt = template_tool.download(bt_path)
6189 6190
        assert marker_list
        if i:
6191 6192
          self.tic()
        bt.install(force=1)
6193
        assert not marker_list
6194
        gc.enable()
6195 6196
        for id in object_id_list:
          self.assertEqual(getattr(portal, id).int_index, i)
6197 6198 6199 6200
        self.tic()
    finally:
      BaseTemplateItem.removeProperties = BaseTemplateItem_removeProperties
      SimpleItem._getCopy = SimpleItem_getCopy
6201
      gc.enable()
6202 6203
    # check the previously existing instance now behaves as the overriden class
    self.assertTrue(getattr(portal.another_file, 'isClassOverriden', False))
6204
    # test uninstall is effective
6205
    self.uninstallBusinessTemplate('test_bt')
6206 6207
    # check both File instances no longer behave like being overriden
    self.assertFalse(getattr(portal.another_file, 'isClassOverriden', False))
6208

6209
  def test_type_provider(self):
6210
    self.portal.newContent(id='dummy_type_provider', portal_type="Types Tool")
6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221
    type_provider = self.portal.dummy_type_provider
    types_tool = self.portal.portal_types

    registered_type_provider_list = types_tool.type_provider_list
    # register this type provider
    types_tool.type_provider_list = (
        'dummy_type_provider',) + registered_type_provider_list

    dummy_type = type_provider.newContent(
                             portal_type='Base Type',
                             id='Dummy Type',
6222
                             type_class='Folder',
6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262
                             type_property_sheet_list=('Reference',),
                             type_base_category_list=('source',),
                             type_allowed_content_type_list=('Dummy Type',),
                             type_hidden_content_type_list=('Dummy Type',) )

    dummy_type.newContent(portal_type='Action Information',
                          reference='view',
                          title='View', )

    dummy_type.newContent(portal_type='Role Information',
                          title='Dummy Role Definition',
                          role_name_list=('Assignee', ))

    pw = self.getWorkflowTool()
    cbt = pw._chains_by_type.copy()
    props = {}
    for id, wf_ids in cbt.items():
      props['chain_%s' % id] = ','.join(wf_ids)
    props['chain_Dummy Type'] = 'edit_workflow'
    pw.manage_changeWorkflows('', props=props)
    self.assertEquals(('edit_workflow', ), pw.getChainFor('Dummy Type'))

    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title='test_bt',
                          template_tool_id_list=('dummy_type_provider', ),
                          template_portal_type_id_list=('Dummy Type',),
                          template_portal_type_role_list=('Dummy Type', ),
                          template_portal_type_workflow_chain_list=(
                             'Dummy Type | edit_workflow',),
                          template_portal_type_allowed_content_type_list=(
                             'Dummy Type | Dummy Type',),
                          template_portal_type_hidden_content_type_list=(
                             'Dummy Type | Dummy Type',),
                          template_portal_type_property_sheet_list=(
                             'Dummy Type | Reference',),
                          template_portal_type_base_category_list=(
                             'Dummy Type | source',),
                          template_action_path_list=(
                             'Dummy Type | view',),)
6263
    self.tic()
6264
    bt.build()
6265
    self.tic()
6266 6267 6268
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
6269
      self.tic()
6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280
      # portal type template item are exported in their physical location
      for template_item in ('PortalTypeTemplateItem',
                            'ActionTemplateItem',):
        self.assertEquals(['dummy_type_provider'],
            [os.path.basename(f) for f in
              glob.glob('%s/%s/*' % (export_dir, template_item))])
      new_bt = self.portal.portal_templates.download(
                        url='file:/%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)

6281
    # uninstall the workflow chain
6282 6283 6284 6285 6286
    pw._chains_by_type = cbt
    # unregister type provider
    types_tool.type_provider_list = registered_type_provider_list
    # uninstall the type provider (this will also uninstall the contained types)
    self.portal.manage_delObjects(['dummy_type_provider'])
6287
    self.tic()
6288

6289
    new_bt.install()
6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301
    try:
      type_provider = self.portal._getOb('dummy_type_provider', None)
      self.assertNotEqual(None, type_provider)

      # This type provider, will be automatically registered on types tool during
      # business template installation, because it contains type information
      self.assertTrue('dummy_type_provider' in types_tool.type_provider_list)
      # The type is reinstalled
      self.assertTrue('Dummy Type' in type_provider.objectIds())
      # is available from types tool
      self.assertTrue('Dummy Type' in [ti.getId() for
                      ti in types_tool.listTypeInfo()])
6302

6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313
      dummy_type = types_tool.getTypeInfo('Dummy Type')
      self.assertNotEquals(None, dummy_type)
      # all the configuration from the type is still here
      self.assertEquals(['Reference'], dummy_type.getTypePropertySheetList())
      self.assertEquals(['source'], dummy_type.getTypeBaseCategoryList())
      self.assertEquals(['Dummy Type'], dummy_type.getTypeAllowedContentTypeList())
      self.assertEquals(['Dummy Type'], dummy_type.getTypeHiddenContentTypeList())

      action_list = dummy_type.contentValues(portal_type='Action Information')
      self.assertEquals(['View'], [action.getTitle() for action in action_list])
      self.assertEquals(['view'], [action.getReference() for action in action_list])
6314

6315 6316 6317
      role_list = dummy_type.contentValues(portal_type='Role Information')
      self.assertEquals(['Dummy Role Definition'],
                        [role.getTitle() for role in role_list])
6318

6319
      self.assertEquals(('edit_workflow',), pw.getChainFor('Dummy Type'))
6320

6321 6322 6323 6324 6325
      # and our type can be used
      instance = self.portal.newContent(portal_type='Dummy Type',
                                        id='test_document')
      instance.setSourceReference('OK')
      self.assertEquals('OK', instance.getSourceReference())
6326

6327 6328 6329 6330 6331
    finally:
      new_bt.uninstall()
      self.assertNotEquals(None, types_tool.getTypeInfo('Base Category'))
      self.assertEquals(None, types_tool.getTypeInfo('Dummy Type'))
      self.assertFalse('dummy_type_provider' in types_tool.type_provider_list)
6332

6333
  def test_type_provider_2(self):
6334
    self.portal.newContent(id='dummy_type_provider', portal_type="Types Tool")
6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346
    type_provider = self.portal.dummy_type_provider
    types_tool = self.portal.portal_types

    registered_type_provider_list = types_tool.type_provider_list
    # register this type provider
    types_tool.type_provider_list = (
        'dummy_type_provider',) + registered_type_provider_list

    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title='test_bt',
                          template_tool_id_list=('dummy_type_provider', ),)
6347
    self.tic()
6348
    bt.build()
6349
    self.tic()
6350 6351 6352
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
6353
      self.tic()
6354 6355 6356 6357 6358 6359 6360 6361 6362
      new_bt = self.portal.portal_templates.download(
                        url='file:/%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)

    # unregister type provider
    types_tool.type_provider_list = registered_type_provider_list
    # uninstall the type provider (this will also uninstall the contained types)
    self.portal.manage_delObjects(['dummy_type_provider'])
6363
    self.tic()
6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378

    new_bt.install()

    type_provider = self.portal._getOb('dummy_type_provider', None)
    self.assertNotEqual(None, type_provider)

    # This type provider, will be automatically registered on types tool during
    # business template installation, because it contains type information
    self.assertTrue('dummy_type_provider' in types_tool.type_provider_list)

    # Create a business template that has the same title but does not
    # contain type_provider.
    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title='test_bt',)
6379
    self.tic()
6380
    bt.build()
6381
    self.tic()
6382 6383 6384
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
6385
      self.tic()
6386 6387 6388 6389 6390 6391 6392 6393 6394
      new_bt = self.portal.portal_templates.download(
                        url='file:/%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)

    new_bt.install(force=0, object_to_update={'dummy_type_provider':'remove'})
    self.assertNotEquals(None, types_tool.getTypeInfo('Base Category'))
    self.assertFalse('dummy_type_provider' in types_tool.type_provider_list)

6395 6396 6397 6398 6399 6400 6401 6402 6403 6404
  def test_global_action(self):
    # Tests that global actions are properly exported and reimported
    self.portal.portal_actions.addAction(
          id='test_global_action',
          name='Test Global Action',
          action='',
          condition='',
          permission='',
          category='object_view')
    action_idx = len(self.portal.portal_actions._actions)
6405

6406 6407 6408 6409 6410
    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title='test_bt',
                          template_action_path_list=(
                             'portal_actions | test_global_action',),)
6411
    self.tic()
6412
    bt.build()
6413
    self.tic()
6414 6415 6416
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
6417
      self.tic()
6418 6419 6420 6421 6422 6423 6424 6425 6426
      # actions are exported in portal_types/ and then the id of the container
      # tool
      self.assertEquals(['portal_actions'],
            [os.path.basename(f) for f in
              glob.glob('%s/ActionTemplateItem/portal_types/*' % (export_dir, ))])
      new_bt = self.portal.portal_templates.download(
                        url='file:/%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)
6427

6428 6429
    # manually uninstall the action
    self.portal.portal_actions.deleteActions(selections=[action_idx])
6430
    self.tic()
6431 6432 6433 6434

    # install the business template and make sure the action is properly
    # installed
    new_bt.install()
6435
    self.tic()
6436 6437 6438
    self.assertNotEquals(None,
        self.portal.portal_actions.getActionInfo('object_view/test_global_action'))

6439 6440 6441 6442 6443 6444 6445 6446 6447 6448
  def test_indexation_of_updated_path_item(self):
    """Tests indexation on updated paths item.
    They should keep their uid and still be available to catalog
    This test is similar to test_40_BusinessTemplateUidOfCategoriesUnchanged,
    but it also checks the object is available to catalog.
    """
    self.portal.newContent(
            id='exported_path',
            title='Exported',
            portal_type='Folder')
6449
    self.tic()
6450 6451 6452 6453 6454 6455 6456 6457

    uid = self.portal.exported_path.getUid()

    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title='test_bt',
                          template_path_list=(
                            'exported_path',))
6458
    self.tic()
6459
    bt.build()
6460
    self.tic()
6461 6462 6463
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
6464
      self.tic()
6465 6466 6467 6468
      new_bt = self.portal.portal_templates.download(
                        url='file:/%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)
6469

6470 6471
    # modify the document
    self.portal.exported_path.setTitle('Modified')
6472
    self.tic()
6473 6474 6475 6476 6477 6478 6479 6480 6481 6482

    # install the business template
    new_bt.install()

    # after installation, the exported document is replaced with the one from
    # the business template
    self.assertEquals('Exported', self.portal.exported_path.getTitle())
    # but its uid did not change
    self.assertEquals(uid, self.portal.exported_path.getUid())
    # and it is still in the catalog
6483
    self.tic()
6484 6485 6486
    self.assertEquals(self.portal.exported_path,
        self.portal.portal_catalog.getResultValue(uid=uid))

6487
  @expectedFailure
6488
  def test_build_and_export_bt5_into_same_transaction(self):
Lucas Carvalho's avatar
Lucas Carvalho committed
6489
    """
6490 6491 6492
      Copy, build and export a business template into the same transaction.

      Make sure all objects can be exported, when build() and export() are
6493
      into the same transaction.
6494

6495
      NOTES:
6496
       - it works for some business templates. (e.g. erp5_base)
6497
       - the object which does not have ._p_jar property is always an
6498
         ActionTemplateItem.
Lucas Carvalho's avatar
Lucas Carvalho committed
6499
    """
6500 6501
    portal = self.getPortalObject()
    template_tool = portal.portal_templates
6502
    # Try with erp5_base, which contais ActionTemplateItem and works.
6503
    bt5obj = template_tool.getInstalledBusinessTemplate('erp5_base')
6504 6505 6506 6507 6508 6509 6510 6511 6512
    template_copy = template_tool.manage_copyObjects(ids=(bt5obj.getId(),))
    new_id_list = template_tool.manage_pasteObjects(template_copy)

    new_bt5_id = new_id_list[0]['new_id']
    new_bt5_obj = getattr(template_tool, new_bt5_id, None)
    new_bt5_obj.edit()
    new_bt5_obj.build()
    template_tool.export(new_bt5_obj)

6513 6514 6515
    # Use erp5_barcode because it contains ActionTemplateItem, which seems to
    # cause problems to be export. Maybe create a test bt5 with all items could
    # be more appropriated.
6516
    bt5obj = template_tool.getInstalledBusinessTemplate('erp5_core')
Lucas Carvalho's avatar
Lucas Carvalho committed
6517
    # it is required to copy and paste to be able to export it
6518 6519
    template_copy = template_tool.manage_copyObjects(ids=(bt5obj.getId(),))
    new_id_list = template_tool.manage_pasteObjects(template_copy)
Lucas Carvalho's avatar
Lucas Carvalho committed
6520

6521 6522 6523 6524 6525 6526
    new_bt5_id = new_id_list[0]['new_id']
    new_bt5_obj = getattr(template_tool, new_bt5_id, None)
    new_bt5_obj.edit()
    new_bt5_obj.build()
    template_tool.export(new_bt5_obj)

6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555
  def test_local_roles_group_id(self):
    """Tests that roles definition defining local roles group ids are properly
    exported and installed.
    """
    # change security uid columns
    sql_catalog = self.portal.portal_catalog.getSQLCatalog()
    saved_sql_catalog_security_uid_columns = \
      sql_catalog.sql_catalog_security_uid_columns

    sql_catalog.sql_catalog_security_uid_columns = (
      ' | security_uid',
      'Alternate | alternate_security_uid',
    )

    types_tool = self.portal.portal_types
    object_type = types_tool.newContent('Geek Object', 'Base Type',
                                type_class='Person')

    types_tool.newContent('Geek Module', 'Base Type',
      type_class='Folder',
      type_filter_content_type=1,
      type_allowed_content_type_list=('Geek Object',), )

    self.portal.newContent(portal_type='Geek Module', id='geek_module')
    new_object = self.portal.geek_module.newContent(
      portal_type='Geek Object', id='1')

    # simulate role assignment
    new_object.__ac_local_roles__ = dict(group=['Assignee'])
6556 6557
    initial___ac_local_roles_group_id_dict__ = dict(Alternate=set([('group', 'Assignee')]))
    new_object.__ac_local_roles_group_id_dict__ = initial___ac_local_roles_group_id_dict__
Ivan Tyagov's avatar
Ivan Tyagov committed
6558
    self.tic()
6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570

    object_type.newContent(portal_type='Role Information',
                           local_roles_group_id='Alternate',
                           role_name_list=('Assignee', ))

    bt = self.portal.portal_templates.newContent(
                          portal_type='Business Template',
                          title=self.id(),
                          template_local_roles_list=('geek_module/1',),
                          template_path_list=('geek_module/1',),
                          template_portal_type_role_list=('Geek Object',),)

Ivan Tyagov's avatar
Ivan Tyagov committed
6571
    self.tic()
6572
    bt.build()
Ivan Tyagov's avatar
Ivan Tyagov committed
6573
    self.tic()
6574 6575 6576
    export_dir = tempfile.mkdtemp()
    try:
      bt.export(path=export_dir, local=True)
Ivan Tyagov's avatar
Ivan Tyagov committed
6577
      self.tic()
6578 6579 6580 6581 6582 6583 6584 6585
      new_bt = self.portal.portal_templates.download(
                        url='file://%s' % export_dir)
    finally:
      shutil.rmtree(export_dir)

    # uninstall role information and paths
    object_type.manage_delObjects([x.id for x in object_type.getRoleInformationList()])
    self.portal.geek_module.manage_delObjects(['1'])
Ivan Tyagov's avatar
Ivan Tyagov committed
6586
    self.tic()
6587 6588 6589 6590 6591 6592 6593 6594

    new_bt.install()
    try:
      role, = object_type.getRoleInformationList()
      self.assertEquals('Alternate', role.getLocalRolesGroupId())
      path = self.portal.geek_module['1']
      self.assertEquals([('group', ['Assignee'],)], [item for item in
            path.__ac_local_roles__.items() if item[1] != ['Owner']])
6595
      self.assertEquals(initial___ac_local_roles_group_id_dict__,
6596 6597 6598 6599 6600 6601 6602
        path.__ac_local_roles_group_id_dict__)
    finally:
      # restore state
      sql_catalog.sql_catalog_security_uid_columns = \
        saved_sql_catalog_security_uid_columns
      types_tool.manage_delObjects(['Geek Object', 'Geek Module'])
      self.portal.manage_delObjects(['geek_module'])
Ivan Tyagov's avatar
Ivan Tyagov committed
6603
      self.tic()
6604

6605 6606 6607 6608 6609 6610 6611 6612
  def test_BusinessTemplateWithTest(self):
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateTest \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddTestToBusinessTemplate \
                       CheckModifiedBuildingState \
6613 6614 6615 6616 6617 6618 6619 6620
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642
                       RemoveTest \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckTestExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckTestRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735
  def stepSetVersionPriorityRegisteredSelection(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    self.failIf(bt is None)

    version_priority_list = ('abc| 1.0',
                             'def |99.0',
                             'erp4')

    bt.edit(template_registered_version_priority_selection_list=version_priority_list)

    sequence.edit(expected_version_priority_list=('def | 99.0',
                                                  'abc | 1.0',
                                                  'erp5 | 0.0',
                                                  'erp4 | 0.0'),
                  current_bt_version_priority_list=tuple(sorted(version_priority_list)))

  def stepUpdateVersionPriorityRegisteredSelection(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    self.failIf(bt is None)

    version_priority_list = ('erp4',
                             'abc | 1.0',
                             'foo | 2.0',
                             'bar | 100.0')

    bt.edit(template_registered_version_priority_selection_list=version_priority_list)

    sequence.edit(expected_version_priority_list=('bar | 100.0',
                                                  'foo | 2.0',
                                                  'abc | 1.0',
                                                  'erp5 | 0.0',
                                                  'erp4 | 0.0'),
                  current_bt_version_priority_list=tuple(sorted(version_priority_list)))

  def stepCheckVersionPriorityRegisteredSelection(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    self.assertEqual(tuple(bt.getTemplateRegisteredVersionPrioritySelectionList()),
                     sequence['current_bt_version_priority_list'])

  def stepRemoveVersionPriorityRegisteredSelectionBeforeImport(self,
                                                               sequence=None,
                                                               **kw):
    bt = sequence.get('current_bt')
    bt.edit(template_registered_version_priority_selection_list=())

  def stepCheckVersionPrioritySetOnSite(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    self.assertEqual(self.getPortalObject().getVersionPriorityList(),
                     sequence['expected_version_priority_list'])

  def stepCheckVersionPriorityRemovedFromSite(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    self.assertEqual(self.getPortalObject().getVersionPriorityList(),
                     ('erp5 | 0.0',))

  def stepRemoveVersionPriorityRegisteredSelection(self, sequence=None, **kw):
    bt = sequence.get('current_bt')
    bt.edit(template_registered_version_priority_selection=())
    sequence.edit(expected_version_priority_list=('erp5 | 0.0'),
                  current_bt_version_priority_list=())

  def test_BusinessTemplateWithVersionPrioritySelection(self):
    sequence_list = SequenceList()
    sequence_string = 'CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       SetVersionPriorityRegisteredSelection \
                       BuildBusinessTemplate \
                       SaveBusinessTemplate \
                       RemoveVersionPriorityRegisteredSelectionBeforeImport \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckVersionPriorityRegisteredSelection \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckVersionPrioritySetOnSite \
                       UninstallBusinessTemplate \
                       Tic \
                       CheckVersionPriorityRemovedFromSite \
                       \
                       UpdateVersionPriorityRegisteredSelection \
                       BuildBusinessTemplate \
                       CheckVersionPriorityRegisteredSelection \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckVersionPrioritySetOnSite \
                       UninstallBusinessTemplate \
                       Tic \
                       CheckVersionPriorityRemovedFromSite \
                       '

    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

6736 6737
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent

6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795
class TestDocumentTemplateItem(BusinessTemplateMixin):
  document_title = 'UnitTest'
  document_data = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'"""
  document_data_updated = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'
  def updated(self):
    pass"""
  document_base_path = os.path.join(getConfiguration().instancehome, 'Document')
  template_property = 'template_document_id_list'

  def stepCreateDocument(self, sequence=None, **kw):
    file_path = os.path.join(self.document_base_path, self.document_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(self.document_data)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(document_title=self.document_title, document_path=file_path,
        document_data=self.document_data)

  def stepCreateUpdatedDocument(self, sequence=None, **kw):
    file_path = os.path.join(self.document_base_path, self.document_title+'.py')
    if os.path.exists(file_path):
      os.remove(file_path)
    f = file(file_path, 'w')
    f.write(self.document_data_updated)
    f.close()
    self.failUnless(os.path.exists(file_path))
    sequence.edit(document_title=self.document_title, document_path=file_path,
        document_data_updated=self.document_data_updated)

  def stepAddDocumentToBusinessTemplate(self, sequence=None, **kw):
    bt = sequence['current_bt']
    bt.edit(**{self.template_property: [sequence['document_title']]})

  def stepRemoveDocument(self, sequence=None, **kw):
    document_path = sequence['document_path']
    os.remove(document_path)
    self.failIf(os.path.exists(document_path))

  def stepCheckDocumentExists(self, sequence=None, **kw):
    self.failIf(not os.path.exists(sequence['document_path']))
    self.assertEqual(file(sequence['document_path']).read(),
        sequence['document_data'])

  def stepCheckUpdatedDocumentExists(self, sequence=None, **kw):
    self.failIf(not os.path.exists(sequence['document_path']))
    self.assertEqual(file(sequence['document_path']).read(),
        sequence['document_data_updated'])

  def stepCheckDocumentRemoved(self, sequence=None, **kw):
    self.failIf(os.path.exists(sequence['document_path']))

  def test_BusinessTemplateWithDocument(self):
6796 6797
    sequence_list = SequenceList()
    sequence_string = '\
6798 6799 6800 6801 6802
                       CreateDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
                       CheckModifiedBuildingState \
6803 6804 6805 6806 6807 6808 6809 6810
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6811 6812 6813 6814 6815 6816
                       RemoveDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
6817
                       CheckNotInstalledInstallationState \
6818
                       InstallWithoutForceBusinessTemplate \
6819 6820 6821 6822
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
6823
                       CheckSkinsLayers \
6824
                       CheckDocumentExists \
6825 6826 6827 6828 6829 6830 6831 6832
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckDocumentRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

6833
  def test_BusinessTemplateUpdateWithDocument(self):
6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
6862 6863 6864 6865 6866 6867 6868 6869 6870
                       CheckDocumentExists \
                       RemoveDocument \
                       CreateUpdatedDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
6871 6872
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6873
                       CheckObjectPropertiesInBusinessTemplate \
6874
                       SaveBusinessTemplate \
6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CreateDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckUpdatedDocumentExists \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckDocumentRemoved \
6891 6892
                       '
    sequence_list.addSequenceString(sequence_string)
6893
    sequence_list.play(self)
6894

6895
  def test_BusinessTemplateWithDocumentNonExistingBefore(self):
6896 6897
    sequence_list = SequenceList()
    sequence_string = '\
6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       \
6922 6923 6924 6925
                       CreateDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
6926
                       CheckModifiedBuildingState \
6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
6938 6939 6940 6941
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6942
                       InstallWithoutForceBusinessTemplate \
6943 6944 6945
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
6946 6947
                       CheckNoTrashBin \
                       CheckSkinsLayers \
6948
                       CheckDocumentExists \
6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckDocumentRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_BusinessTemplateWithDocumentPropertySheetMigrated(self):
    """Checks that if Business Template defines Document and PropertySheet
    Document is not removed after Property Sheet was migrated and Business Template
    was updated"""
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateDocument \
                       CreatePropertySheet \
                       CheckDocumentPropertySheetSameName \
6966 6967 6968
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
6969
                       AddPropertySheetToBusinessTemplate \
6970 6971 6972 6973 6974 6975 6976 6977 6978
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6979 6980
                       RemoveDocument \
                       RemovePropertySheet \
6981 6982 6983 6984 6985 6986
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
6987
                       InstallWithoutForceBusinessTemplate \
6988
                       Tic \
6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckDocumentExists \
                       CheckPropertySheetExists \
                       \
                       SimulateAndCopyPrePropertySheetMigrationBusinessTemplate \
                       Tic \
                       \
                       CreateAllPropertySheetsFromFilesystem \
                       Tic \
                       CheckPropertySheetRemoved \
                       CheckPropertySheetMigration \
                       \
                       CheckDraftBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       Tic \
                       CreatePropertySheet \
                       RemovePropertySheetZodbOnly \
                       Tic \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
                       CheckPropertySheetMigration \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckDocumentExists \
                       CheckPropertySheetRemoved \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  # Specific to ZODB Components *only*
  def getBusinessTemplateList(self):
    return (super(TestDocumentTemplateItem, self).getBusinessTemplateList() +
            ('erp5_core_component',))

  component_module = DocumentComponent._getDynamicModuleNamespace()
  component_portal_type = DocumentComponent.portal_type

  def stepCreateZodbDocument(self, sequence=None, **kw):
7042
    document_id = self.component_module + '.erp5.' + self.document_title
7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054
    self.getPortalObject().portal_components.newContent(
      id=document_id,
      version='erp5',
      reference=self.document_title,
      text_content=self.document_data,
      portal_type=self.component_portal_type)

    sequence.edit(document_title=self.document_title,
                  document_id=document_id,
                  document_data=self.document_data)

  def stepAddZodbDocumentToBusinessTemplate(self, sequence=None, **kw):
7055 7056
    getattr(sequence['current_bt'], self.set_template_id_method_name)(
      sequence['document_id'])
7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079

  def stepRemoveZodbDocument(self, sequence=None, **kw):
    self.getPortalObject().portal_components.deleteContent(
      sequence['document_id'])

  def stepCheckZodbDocumentExists(self, sequence=None, **kw):
    self.assertHasAttribute(self.getPortalObject().portal_components,
                            sequence['document_id'])

  def stepCheckZodbDocumentRemoved(self, sequence=None, **kw):
    component_tool = self.getPortalObject().portal_components
    self.failIf(sequence['document_id'] in component_tool.objectIds())

  def stepRemoveZodbDocument(self, sequence=None, **kw):
    self.portal.portal_components.manage_delObjects([sequence['document_id']])

  def stepCheckForkedMigrationExport(self, sequence=None, **kw):
    """
    After saving a Business Template, two files should have been created for
    each Component, one is the Python source code (ending with '.py') and the
    other one is the metadata (ending with '.xml')
    """
    component_bt_tool_path = os.path.join(sequence['template_path'],
7080
                                          self.__class__.__name__[len('Test'):],
7081 7082 7083 7084
                                          'portal_components')

    self.assertTrue(os.path.exists(component_bt_tool_path))

7085
    component_id = self.component_module + '.erp5.' + sequence['document_title']
7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133
    base_path = os.path.join(component_bt_tool_path, component_id)

    python_source_code_path = base_path + '.py'
    self.assertTrue(os.path.exists(python_source_code_path))

    source_code = sequence['document_data']
    with open(python_source_code_path) as f:
      self.assertEquals(f.read(), source_code)

    xml_path = base_path + '.xml'
    self.assertTrue(os.path.exists(xml_path))

    first_line = source_code.split('\n', 1)[0]
    with open(xml_path) as f:
      for line in f:
        self.failIf(first_line in line)

  def test_BusinessTemplateWithZodbDocument(self):
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateZodbDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddZodbDocumentToBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckForkedMigrationExport \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveZodbDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       CheckZodbDocumentExists \
7134 7135 7136
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7137 7138 7139
                       CheckZodbDocumentRemoved \
                       SaveBusinessTemplate \
                       CheckForkedMigrationExport \
7140 7141 7142 7143
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

7144
  def test_BusinessTemplateWithZodbDocumentNonExistingBefore(self):
7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7164
                       InstallWithoutForceBusinessTemplate \
7165 7166 7167 7168 7169 7170
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
                       \
7171
                       CreateZodbDocument \
7172 7173
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
7174
                       AddZodbDocumentToBusinessTemplate \
7175 7176 7177 7178 7179 7180 7181
                       CheckModifiedBuildingState \
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
7182
                       CheckForkedMigrationExport \
7183 7184
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7185
                       RemoveZodbDocument \
7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckSkinsLayers \
7198
                       CheckZodbDocumentExists \
7199 7200 7201
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7202
                       CheckZodbDocumentRemoved \
7203 7204 7205 7206
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221
  set_template_id_method_name = 'setTemplateDocumentId'

  def stepCopyAndMigrateDocumentBusinessTemplate(self, sequence=None, **kw):
    """
    Simulate migration from filesystem to ZODB

    XXX-arnau: implement importer at BusinessTemplate level
    """
    portal = self.getPortalObject()
    template_tool = portal.portal_templates
    current_bt = sequence['current_bt']
    cb_data = template_tool.manage_copyObjects([current_bt.getId()])
    copied, = template_tool.manage_pasteObjects(cb_data)
    copied_bt = template_tool._getOb(copied['new_id'])
    getattr(copied_bt, self.set_template_id_method_name)(sequence['document_id'])
7222
    self.commit()
7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234
    sequence.edit(current_bt=copied_bt)

  importFromFilesystem = DocumentComponent.importFromFilesystem

  def stepImportDocumentFromFilesystem(self, sequence=None, **kw):
    """
    Import a Component from Filesystem to ZODB
    """
    component_tool = self.getPortalObject().portal_components

    document_object = self.importFromFilesystem(
      component_tool,
7235 7236
      sequence['document_title'],
      'erp5')
7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253

    sequence.edit(document_id=document_object.getId())

  def stepCheckDocumentMigration(self, sequence=None, **kw):
    """
    Check migration of Document from the Filesystem to ZODB
    """
    component_id = sequence['document_id']
    component_tool = self.getPortalObject().portal_components
    self.failUnless(component_id in component_tool.objectIds())

    component = getattr(component_tool, component_id)
    self.assertEquals(component.getReference(), sequence['document_title'])
    self.assertEquals(component.getTextContent(), sequence['document_data'])
    self.assertEquals(component.getPortalType(), self.component_portal_type)

  def test_BusinessTemplateWithZodbDocumentMigrated(self):
7254 7255 7256 7257 7258 7259 7260 7261 7262 7263
    """Checks that if Business Template defines Document and PropertySheet
    Document is not removed after Property Sheet was migrated and Business Template
    was updated"""
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateDocument \
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
                       CheckModifiedBuildingState \
7264 7265 7266 7267 7268 7269 7270 7271
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7272 7273 7274 7275 7276 7277 7278
                       RemoveDocument \
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7279
                       InstallWithoutForceBusinessTemplate \
7280 7281 7282 7283 7284 7285
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckDocumentExists \
                       \
7286
                       ImportDocumentFromFilesystem \
7287
                       Tic \
7288 7289 7290
                       CheckDocumentRemoved \
                       CheckDocumentMigration \
                       CopyAndMigrateDocumentBusinessTemplate \
7291 7292 7293
                       Tic \
                       \
                       CheckDraftBuildingState \
7294 7295 7296 7297 7298 7299
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
7300
                       CheckForkedMigrationExport \
7301 7302
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7303
                       RemoveBusinessTemplate \
7304
                       RemoveZodbDocument \
7305 7306 7307 7308 7309 7310 7311 7312
                       Tic \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       InstallWithoutForceBusinessTemplate \
                       Tic \
                       \
7313
                       CheckZodbDocumentExists \
7314 7315
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
7316 7317 7318 7319 7320
                       \
                       UninstallBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckZodbDocumentRemoved \
7321 7322 7323 7324
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

7325
class TestConstraintTemplateItem(TestDocumentTemplateItem):
7326 7327 7328 7329 7330 7331 7332
  document_title = 'UnitTest'
  document_data = ' \nclass UnitTest: \n  """ \n  Fake constraint for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
  document_data_updated = ' \nclass UnitTest2: \n  """ \n  Second Fake constraint for unit test \n \
    """ \n  _properties = ( \n  ) \n  _categories = ( \n  ) \n\n'
  document_base_path = os.path.join(getConfiguration().instancehome, 'Constraint')
  template_property = 'template_constraint_id_list'
7333

7334 7335
from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent

7336
class TestExtensionTemplateItem(TestDocumentTemplateItem):
7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347
  document_title = 'UnitTest'
  document_data = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'"""
  document_data_updated = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'
  def updated(self):
    pass"""
  document_base_path = os.path.join(getConfiguration().instancehome, 'Extensions')
  template_property = 'template_extension_id_list'
7348

7349
  # Specific to ZODB Extension Component
7350 7351
  component_module = ExtensionComponent._getDynamicModuleNamespace()
  component_portal_type = ExtensionComponent.portal_type
7352 7353
  importFromFilesystem = ExtensionComponent.importFromFilesystem
  set_template_id_method_name = 'setTemplateExtensionId'
7354

7355 7356
from Products.ERP5Type.Core.TestComponent import TestComponent

7357
class TestTestTemplateItem(TestDocumentTemplateItem):
7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369
  document_title = 'UnitTest'
  document_data = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'"""
  document_data_updated = """class UnitTest:
  meta_type = 'ERP5 Unit Test'
  portal_type = 'Unit Test'
  def updated(self):
    pass"""
  document_base_path = os.path.join(getConfiguration().instancehome, 'tests')
  template_property = 'template_test_id_list'

7370 7371 7372 7373 7374 7375
  # Specific to ZODB Extension Component
  component_module = TestComponent._getDynamicModuleNamespace()
  component_portal_type = TestComponent.portal_type
  importFromFilesystem = TestComponent.importFromFilesystem
  set_template_id_method_name = 'setTemplateTestId'

7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390
  def stepAddTestToBusinessTemplate(self, sequence=None, **kw):
    bt = sequence['current_bt']
    bt.edit(template_test_id_list=[sequence['test_title']])

  def stepCheckDocumentTestSameName(self, sequence=None, **kw):
    self.assertEqual(sequence['test_title'], sequence['document_title'])
    self.assertEqual(os.path.basename(sequence['document_path']),
        os.path.basename(sequence['test_path']))

  def stepRemoveTestFromBusinessTemplate(self, sequence=None, **kw):
    """
    Add Property Sheet to Business Template
    """
    sequence['current_bt'].edit(template_test_id_list=[])

7391 7392 7393
  def test_BusinessTemplateWithDocumentTestRemoved(self):
    """Checks that if Business Template defines Document and Test
    Document is not removed"""
7394 7395
    self.document_base_path = os.path.join(getConfiguration().instancehome, 'Document')
    self.template_property = 'template_document_id_list'
7396 7397 7398
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateDocument \
7399 7400
                       CreateTest \
                       CheckDocumentTestSameName \
7401 7402 7403
                       CreateNewBusinessTemplate \
                       UseExportBusinessTemplate \
                       AddDocumentToBusinessTemplate \
7404
                       AddTestToBusinessTemplate \
7405
                       CheckModifiedBuildingState \
7406 7407 7408 7409 7410 7411 7412 7413
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7414
                       RemoveDocument \
7415
                       RemoveTest \
7416 7417 7418 7419 7420 7421
                       RemoveBusinessTemplate \
                       RemoveAllTrashBins \
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7422
                       InstallWithoutForceBusinessTemplate \
7423 7424 7425 7426 7427
                       Tic \
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
                       CheckNoTrashBin \
                       CheckDocumentExists \
7428 7429 7430 7431 7432 7433
                       CheckTestExists \
                       \
                       CopyBusinessTemplate \
                       Tic \
                       \
                       RemoveTestFromBusinessTemplate \
7434
                       CheckModifiedBuildingState \
7435 7436 7437 7438 7439 7440 7441 7442
                       CheckNotInstalledInstallationState \
                       BuildBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
                       CheckObjectPropertiesInBusinessTemplate \
                       SaveBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7443 7444 7445 7446
                       ImportBusinessTemplate \
                       UseImportBusinessTemplate \
                       CheckBuiltBuildingState \
                       CheckNotInstalledInstallationState \
7447
                       InstallWithoutForceBusinessTemplate \
7448
                       Tic \
7449
                       \
7450 7451
                       CheckInstalledInstallationState \
                       CheckBuiltBuildingState \
7452
                       CheckTestRemoved \
7453 7454 7455 7456 7457
                       CheckDocumentExists \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

7458
# XXX-arnau: Skip until ZODB Constraints have been implemented (not
7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469
# expectedFailure because following tests would fail after the ZODB Component
# has been created)
TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocument = skip(
  'Not implemented yet')(TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocument)

TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocumentNonExistingBefore = \
    skip('Not implemented yet')(TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocumentNonExistingBefore)

TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocumentMigrated = \
    skip('Not implemented yet')(TestConstraintTemplateItem.test_BusinessTemplateWithZodbDocumentMigrated)

7470 7471 7472
def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestBusinessTemplate))
7473 7474 7475 7476
  suite.addTest(unittest.makeSuite(TestConstraintTemplateItem))
  suite.addTest(unittest.makeSuite(TestDocumentTemplateItem))
  suite.addTest(unittest.makeSuite(TestExtensionTemplateItem))
  suite.addTest(unittest.makeSuite(TestTestTemplateItem))
7477
  return suite