testBusinessTemplate.py 23.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
##############################################################################
#
# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved.
#          Yoshinori Okuji <yo@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################

#
# Skeleton ZopeTestCase
#

from random import randint

import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

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

from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
from DateTime import DateTime
from Acquisition import aq_base, aq_inner
from zLOG import LOG
from Products.ERP5Type.ERP5Type import ERP5TypeInformation
import time
import os
from Products.ERP5Type import product_path
from DateTime import DateTime
54
from App.config import getConfiguration
Romain Courteaud's avatar
Romain Courteaud committed
55
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
Aurel's avatar
Aurel committed
56
from urllib import pathname2url
57 58 59 60 61 62 63 64 65 66 67 68 69

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

    - Create a template

    - Install a template

    - Uninstall a template

    - Upgrade a template
  """
Romain Courteaud's avatar
Romain Courteaud committed
70 71
  run_all_test = 1
  business_template_title = 'erp5_pdm'
Yoshinori Okuji's avatar
Yoshinori Okuji committed
72 73 74
  
  def getTitle(self):
    return "Business Template"
75

Romain Courteaud's avatar
Romain Courteaud committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
  def getBusinessTemplateList(self):
    """
    Install erp5_pdm in order to make some test on it.
    """
    return (self.business_template_title, )

  def enableActivityTool(self):
    """
    You can override this.
    Return if we should create (1) or not (0) an activity tool.
    """
    return 1

  def stepTic(self,**kw):
    self.tic()

  def test_01_checkTools(self, quiet=0, run=run_all_test):
    if not run: return
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
    if not quiet:
      message = 'Test Check Tools'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    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)
    
  def test_02_checkERP5Core(self, quiet=0):
    if not quiet:
      message = 'Test Check ERP5 Core'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    pt = self.getTemplateTool()
    core = None
    for bt in pt.objectValues(filter={'portal_type':'Business Template'}):
      if bt.getTitle() == 'erp5_core':
        core = bt
    self.failUnless(core is not None)
115 116
    self.assertEquals(core.getBuildingState(), 'built')
    self.assertEquals(core.getInstallationState(), 'installed')
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    
  def afterSetUp(self):
    self.login()
    portal = self.getPortal()
    catalog_tool = self.getCatalogTool()

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

  def makeObjects(self):
    """
      Make objects to create a template.
    """
    # Make types.
    pt = self.getTypeTool()
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type, id='Geek Module', typeinfo_name='ERP5Type: ERP5 Folder')
    module_type = pt._getOb('Geek Module', None)
    self.failUnless(module_type is not None)
    pt.manage_addTypeInformation(ERP5TypeInformation.meta_type, id='Geek', typeinfo_name='ERP5Type: ERP5 Person')
    object_type = pt._getOb('Geek', None)
    self.failUnless(object_type is not None)
    module_type.allowed_content_types = ('Geek',)

    # Make skin folders.
    ps = self.getSkinsTool()
    ps.manage_addProduct['OFSP'].manage_addFolder('local_geek')
    skin_folder = ps._getOb('local_geek', None)
    self.failUnless(skin_folder is not None)
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
      if 'local_geek' not in selection:
        selection.append('local_geek')
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)

    # Make modules.
    portal = self.getPortal()
    module = portal.newContent(id = 'geek', portal_type = 'Geek Module')
    self.failUnless(module is not None)
    object = module.newContent(id = '1', portal_type = 'Geek')
    self.failUnless(object is not None)

    # Make categories.
    pc = self.getCategoryTool()
    base_category = pc.newContent(portal_type = 'Base Category', id = 'geek')
    self.failUnless(base_category is not None)
    category = base_category.newContent(portal_type = 'Category', id = 'computer')
    self.failUnless(category is not None)
    category = base_category.newContent(portal_type = 'Category', id = 'manga')
    self.failUnless(category is not None)
    category = base_category.newContent(portal_type = 'Category', id = 'game')
    self.failUnless(category is not None)

    # Make workflows.
    pw = self.getWorkflowTool()
    pw.manage_addWorkflow('dc_workflow (Web-configurable workflow)', 'geek_workflow')
    cbt = pw._chains_by_type
    props = {}
    if cbt is not None:
      for id, wf_ids in cbt.items():
        props['chain_%s' % id] = ','.join(wf_ids)
    props['chain_geek'] = 'geek_workflow'
    pw.manage_changeWorkflows('', props=props)

    # FIXME: more objects must be created.

  def removeObjects(self):
    """
      Remove objects created by makeObjects.
    """
    # Remove types.
    pt = self.getTypeTool()
    pt.manage_delObjects(['Geek Module', 'Geek'])
    module_type = pt._getOb('Geek Module', None)
    self.failUnless(module_type is None)
    object_type = pt._getOb('Geek', None)
    self.failUnless(object_type is None)

    # Remove skin folders.
    ps = self.getSkinsTool()
    ps.manage_delObjects(['local_geek'])
    skin_folder = ps._getOb('local_geek', None)
    self.failUnless(skin_folder is None)
    for skin_name, selection in ps.getSkinPaths():
      selection = selection.split(',')
      if 'local_geek' in selection:
        selection.remove('local_geek')
      ps.manage_skinLayers(skinpath = tuple(selection), skinname = skin_name, add_skin = 1)

    # Remove modules.
    portal = self.getPortal()
    portal.manage_delObjects(['geek'])
    module = portal._getOb('geek', None)
    self.failUnless(module is None)

    # Remove categories.
    pc = self.getCategoryTool()
    pc.manage_delObjects(['geek'])
    base_category = pc._getOb('geek', None)
    self.failUnless(base_category is None)

    # Make workflows.
    pw = self.getWorkflowTool()
    pw.manage_delObjects(['geek_workflow'])

    # FIXME: more objects must be removed.

Romain Courteaud's avatar
Romain Courteaud committed
226 227
  def test_02_makeTemplate(self, quiet=0, run=run_all_test):
    if not run: return
228 229 230 231 232 233 234 235 236 237 238
    if not quiet:
      message = 'Test Make Template'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)

    self.makeObjects()

    pt = self.getTemplateTool()
    template = pt.newContent(portal_type = 'Business Template')
    self.failUnless(template.getBuildingState() == 'draft')
    self.failUnless(template.getInstallationState() == 'not_installed')
239 240
    template.edit(title='geek template',
                  template_portal_type_id_list = ['Geek Module', 'Geek'],
241 242 243 244 245 246 247 248 249
                  template_skin_id_list = ['local_geek'],
                  template_module_id_list = ['geek'],
                  template_base_category_list = ['geek'],
                  template_workflow_id_list = ['geek_workflow'])
    self.failUnless(template.getBuildingState() == 'modified')
    self.failUnless(template.getInstallationState() == 'not_installed')
    template.build()
    self.failUnless(template.getBuildingState() == 'built')
    self.failUnless(template.getInstallationState() == 'not_installed')
250 251 252
    # export Business Template
    cfg = getConfiguration()
    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (template.getTitle(),))
Aurel's avatar
Aurel committed
253
    template.export(path=pathname2url(template_path), local=1)
254 255

    self.removeObjects()
256 257
    
    # import and install Business Template
Aurel's avatar
Aurel committed
258
    pt.download(url='file:'+pathname2url(template_path), id='template_test')
259
    template = pt._getOb(id='template_test')  
260
    template.install()
261 262
    self.assertEquals(template.getBuildingState(), 'built')
    self.assertEquals(template.getInstallationState(), 'installed')
263 264 265 266

    # FIXME: check installed objects here
    
    template.uninstall()
267 268
    self.assertEquals(template.getBuildingState(), 'built')
    self.assertEquals(template.getInstallationState(), 'not_installed')
269 270 271

    # FIXME: check uninstalled objects here

Romain Courteaud's avatar
Romain Courteaud committed
272 273 274 275 276 277 278 279
  def stepGetCurrentBusinessTemplate(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
      Get current business template.
    """
    template_tool = self.getTemplateTool()
    current_bt_sql = template_tool.searchFolder(
                              title=self.business_template_title)
280 281 282 283 284 285 286
    current_bt_list = []
    for bt in current_bt_sql:
      ob = bt.getObject()
      if ob.getInstallationState() == 'installed':
        current_bt_list.append(ob)
    self.assertEquals(len(current_bt_list), 1)
    current_bt = current_bt_list[0]
Romain Courteaud's avatar
Romain Courteaud committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
    sequence.edit(current_bt=current_bt)

  def stepCopyBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
    """
      Copy business template.
    """
    current_bt = sequence.get('current_bt')
    template_tool = self.getTemplateTool()
    copy_data = template_tool.manage_copyObjects(ids=[current_bt.getId()])
    new_id_list = template_tool.manage_pasteObjects(copy_data)
    self.failUnless(len(new_id_list) == 1)
    new_bt = getattr(template_tool, new_id_list[0]['new_id'])
    sequence.edit(new_bt=new_bt)

  def stepCreateNewBaseCategory(self, sequence=None, sequence_list=None, **kw):
    """
      Create new base category.
    """
    category_tool = self.getCategoryTool()
306
    new_base_category = category_tool.newContent(portal_type="Base Category",)
Romain Courteaud's avatar
Romain Courteaud committed
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
    sequence.edit(new_base_category=new_base_category)

  def stepEditNewBT(self, sequence=None, sequence_list=None, **kw):
    """
    Simply edit, in order to change the building status.
    """
    new_bt = sequence.get('new_bt')
    new_bt.edit()

  def stepAddNewBaseCategoryToNewBT(self, sequence=None, 
                                    sequence_list=None, **kw):
    """
    Add the base category to the business template.
    """
    new_bt = sequence.get('new_bt')
    new_base_category = sequence.get('new_base_category')
    base_category_id_list = list(new_bt.getTemplateBaseCategoryList())
    base_category_id_list.append(new_base_category.getId())
    new_bt.edit(template_base_category_list=base_category_id_list)
326
    sequence.edit(installed_base_cat_id=new_base_category.getId())
Romain Courteaud's avatar
Romain Courteaud committed
327

328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
  def stepAddCategoryToBaseCategory(self, sequence=None,
                                    sequence_list=None, **kw):
    """
    Add a category to a base category
    """
    subcategory_id = "fake subcategory"
    new_base_category = sequence.get('new_base_category')
#     portal_categories = self.getCategoryTool()
#     base_category = portal_categories._getOb('fake_base_category')
    LOG('new_base_catory', 0, new_base_category)
    subcategory = new_base_category.newContent(portal_type="Category",
                                           id=subcategory_id)
    sequence.edit(subcategory_id=subcategory.getId())

  def stepCheckIfSubCategoryExists(self, sequence=None,
                                  sequence_list=None, **kw):
    """
    Check if subcategory still exists
    """
    base_category_id = sequence.get('installed_base_cat_id')
    LOG("base_cat_id", 0, base_category_id)
    portal_categories = self.getCategoryTool()
    base_category = portal_categories._getOb(base_category_id)
    subcategory_id = sequence.get('subcategory_id')
    self.failUnless(subcategory_id in base_category.contentIds())

Romain Courteaud's avatar
Romain Courteaud committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
  def stepCheckModifiedBuildingState(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
    Check if the building state is modified.
    """
    new_bt = sequence.get('new_bt')
    self.assertEquals(new_bt.getBuildingState(), 'modified')

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

  def stepBuildNewBT(self, sequence=None, sequence_list=None, **kw):
    """
    Build the business template.
    """
    new_bt = sequence.get('new_bt')
    new_bt.build()

  def stepExportNewBT(self, sequence=None, sequence_list=None, **kw):
    """
    Export the business template.
    """
    new_bt = sequence.get('new_bt')
    cfg = getConfiguration()
    template_path = os.path.join(cfg.instancehome, 
                                 'tests', '%s' % (new_bt.getTitle(),))
    sequence.edit(template_path=template_path)
    new_bt.export(path=template_path, local=1)

  def stepImportNewBT(self, sequence=None, sequence_list=None, **kw):
    """
    Import the business template.
    """
    template_tool = self.getTemplateTool()
393
    new_bt = sequence.get('new_bt')
Romain Courteaud's avatar
Romain Courteaud committed
394
    template_path = sequence.get('template_path')
395
    import_bt_id = "import_%s" % new_bt.getId()
Aurel's avatar
Aurel committed
396
    template_tool.download(url='file:'+pathname2url(template_path), id=import_bt_id)
397
    import_bt = template_tool._getOb(id=import_bt_id)
Romain Courteaud's avatar
Romain Courteaud committed
398 399
    self.assertEquals(import_bt.getPortalType(), 'Business Template')
    sequence.edit(new_bt=import_bt)
400
    template_tool.deleteContent(new_bt.getId())
Romain Courteaud's avatar
Romain Courteaud committed
401 402 403 404 405 406 407

  def stepInstallNewBT(self, sequence=None, sequence_list=None, **kw):
    """
    Build the business template.
    """
    new_bt = sequence.get('new_bt')
    new_bt.install()
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461

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

  def stepSwitchBT(self, sequence=None, sequence_list=None, **kw):
    """
    Replace the current BT by the new.
    And delete the old one.
    """
    new_bt = sequence.get('new_bt')
    current_bt = sequence.get('current_bt')
    template_tool = self.getTemplateTool()
    template_tool.deleteContent(current_bt.getId())
    sequence.edit(
         current_bt=new_bt,
         new_bt=None)

  def stepCheckEmptyDiff(self, sequence=None, sequence_list=None, **kw):
    """
    Check if the diff of the new BT is empty
    """
    new_bt = sequence.get('new_bt')
#     self.assertEquals('', new_bt.diff(verbose=1))
    diff = new_bt.diff(verbose=1)
#     diff_list = diff.split('\n')
#     self.assertEquals(3, len(diff_list))

  def stepCheckNoEmptyDiff(self, sequence=None, sequence_list=None, **kw):
    """
    Check if the diff of the new BT is empty
    """
    new_bt = sequence.get('new_bt')
#     self.assertEquals('', new_bt.diff(verbose=1))
    diff = new_bt.diff(verbose=1)
    diff_list = diff.split('\n')
#     self.assertEquals(4, len(diff_list))

  def stepRemoveBaseCategoryFromNewBT(self, sequence=None, 
                                      sequence_list=None, **kw):
    """
    Remove a base category from the business template.
    """
    new_bt = sequence.get('new_bt')
#     new_base_category = sequence.get('new_base_category')
    base_category_id_list = list(new_bt.getTemplateBaseCategoryList())
    new_bt.edit(template_base_category_list=base_category_id_list[1:])
    sequence.edit(installed_base_cat_id=base_category_id_list[0])

  def stepCheckIfBaseCategoryIsInstalled(self, sequence=None, 
                                         sequence_list=None, **kw):
    """
    Check if a base category is installed.
    """
    base_category_id = sequence.get('installed_base_cat_id')
462
    LOG('base_category_id', 0, base_category_id)
463
    portal_categories = self.getCategoryTool()
464
    LOG("category list", 0, portal_categories.contentIds())
465
    self.failUnless(base_category_id in portal_categories.contentIds())
Romain Courteaud's avatar
Romain Courteaud committed
466

Yoshinori Okuji's avatar
Yoshinori Okuji committed
467 468 469 470 471 472 473 474 475
  def stepCheckIfBaseCategoryIsNotInstalled(self, sequence=None, 
                                         sequence_list=None, **kw):
    """
    Check if a base category is not installed.
    """
    base_category_id = sequence.get('installed_base_cat_id')
    portal_categories = self.getCategoryTool()
    self.failIf(base_category_id in portal_categories.contentIds())

476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
  def stepCheckIfTrashBinExists(self, sequence=None, sequence_list=None, **kw):
    """
    Check If we create a trash bin at upgrade
    """
    new_bt = sequence.get('new_bt')
    self.failUnless(len(new_bt.portal_trash.objectIds()) == 1)

  def stepRemoveAllTrashBins(self, sequence=None, sequence_list=None, **kw):
    """
    Remove all previous trash bins generated
    """
    current_bt = sequence.get('current_bt')
    trash = current_bt.getPortalObject().portal_trash
    trash_ids = trash.objectIds()
    for id in list(trash_ids):
        trash.deleteContent(id)    
    self.failIf(len(trash.objectIds()) > 0)
    
Romain Courteaud's avatar
Romain Courteaud committed
494 495
  def test_03_update(self, quiet=0, run=run_all_test):
    """
496
    Update BT
Romain Courteaud's avatar
Romain Courteaud committed
497 498 499 500 501 502 503 504 505 506 507 508
    """
    if not run: return
    if not quiet:
      message = 'Test Update Template'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      CopyBusinessTemplate \
                      Tic \
                      InstallNewBT \
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
                      CheckEmptyDiff \
                      SwitchBT \
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_04_importExport(self, quiet=0, run=run_all_test):
    """
    Built, export/import, install
    """
    if not run: return
    if not quiet:
      message = 'Test Import/Export'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      CopyBusinessTemplate \
                      EditNewBT \
                      BuildNewBT \
                      CheckBuiltBuildingState \
                      ExportNewBT \
                      ImportNewBT \
                      Tic \
                      InstallNewBT \
                      CheckEmptyDiff \
                      SwitchBT \
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_05_addNewBaseCategory(self, quiet=0, run=run_all_test):
    """
    Test replacing a bt when the new one has a new base category.
    This base category must be of course installed
    """
    if not run: return
    if not quiet:
      message = 'Test Update with new objects'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      CopyBusinessTemplate \
                      CreateNewBaseCategory \
                      AddNewBaseCategoryToNewBT \
                      CheckModifiedBuildingState \
                      BuildNewBT \
                      CheckBuiltBuildingState \
                      ExportNewBT \
                      ImportNewBT \
                      Tic \
                      InstallNewBT \
                      CheckNoEmptyDiff \
                      CheckIfBaseCategoryIsInstalled \
                      SwitchBT \
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_06_removeBaseCategory(self, quiet=0, run=run_all_test):
    """
    Test replacing a bt when the new one has a base category left.
    This base category must be kept on the site.
    """
    if not run: return
    if not quiet:
      message = 'Test Update with less objects'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      CopyBusinessTemplate \
                      RemoveBaseCategoryFromNewBT \
                      CheckModifiedBuildingState \
                      BuildNewBT \
                      CheckBuiltBuildingState \
                      ExportNewBT \
                      ImportNewBT \
                      Tic \
                      InstallNewBT \
                      CheckNoEmptyDiff \
594
                      CheckIfBaseCategoryIsInstalled \
595 596 597 598 599 600 601 602 603 604 605 606
                      SwitchBT \
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def test_07_installWithoutExport(self, quiet=0, run=run_all_test):
    """
    Built, install
    Check the diff
    """
    if not run: return
    if not quiet:
607
      message = 'Test Build and Update without export'
608 609 610 611 612 613 614 615 616 617 618 619 620
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      CopyBusinessTemplate \
                      EditNewBT \
                      BuildNewBT \
                      CheckBuiltBuildingState \
                      Tic \
                      InstallNewBT \
                      CheckEmptyDiff \
                      SwitchBT \
Romain Courteaud's avatar
Romain Courteaud committed
621 622 623
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
624

625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660

  def test_08_checkNoSubobjectsUninstall(self, quiet=0, run=run_all_test):
    """
    Test if we don't remove subobjects when upgrading a
    business tempalte
    """
    if not run: return
    if not quiet:
      message = 'Test if subobjects remains after upgrade'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                      GetCurrentBusinessTemplate \
                      RemoveAllTrashBins \
                      CopyBusinessTemplate \
                      CreateNewBaseCategory \
                      AddCategoryToBaseCategory \
                      AddNewBaseCategoryToNewBT \
                      EditNewBT \
                      BuildNewBT \
                      CheckBuiltBuildingState \
                      ExportNewBT \
                      ImportNewBT \
                      Tic \
                      InstallNewBT \
                      CheckNoEmptyDiff \
                      CheckIfBaseCategoryIsInstalled \
                      CheckIfSubCategoryExists \
                      CheckIfTrashBinExists \
                      SwitchBT \
                      '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)    


661 662 663 664 665 666 667 668
if __name__ == '__main__':
    framework()
else:
    import unittest
    def test_suite():
        suite = unittest.TestSuite()
        suite.addTest(unittest.makeSuite(TestBusinessTemplate))
        return suite