testBase.py 22.6 KB
Newer Older
Romain Courteaud's avatar
Romain Courteaud committed
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 54 55
##############################################################################
#
# Copyright (c) 2004, 2005 Nexedi SARL and Contributors. All Rights Reserved.
#          Romain Courteaud <romain@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.DateUtils import addToDate
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
import time
import os
from Products.ERP5Type import product_path
from Products.CMFCore.utils import getToolByName
56
from Products.ERP5Type.Tool.ClassTool import _aq_reset
Romain Courteaud's avatar
Romain Courteaud committed
57 58 59 60 61

class TestBase(ERP5TypeTestCase):

  run_all_test = 1
  object_portal_type = "Organisation"
62 63
  not_defined_property_id = "azerty_qwerty"
  not_defined_property_value = "qwerty_azerty"
Romain Courteaud's avatar
Romain Courteaud committed
64 65 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105

  def getTitle(self):
    return "Base"

  def getBusinessTemplateList(self):
    """
    """
    return ()

  def login(self, quiet=0, run=run_all_test):
    uf = self.getPortal().acl_users
    uf._doAddUser('rc', '', ['Manager'], [])
    user = uf.getUserById('rc').__of__(uf)
    newSecurityManager(None, user)

  def enableLightInstall(self):
    """
    You can override this. 
    Return if we should do a light install (1) or not (0)
    """
    return 1

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

  def afterSetUp(self, quiet=1, run=run_all_test):
    self.login()
    portal = self.getPortal()
    self.category_tool = self.getCategoryTool()
    portal_catalog = self.getCatalogTool()
    #portal_catalog.manage_catalogClear()
    self.createCategories()

  def createCategories(self):
    """ 
      Light install create only base categories, so we create 
      some categories for testing them
    """
Romain Courteaud's avatar
Romain Courteaud committed
106 107 108 109 110
    category_list = ['testGroup1', 'testGroup2']
    if len(self.category_tool.group.contentValues()) == 0 :
      for category_id in category_list:
        o = self.category_tool.group.newContent(portal_type='Category',
                                                id=category_id)
Romain Courteaud's avatar
Romain Courteaud committed
111 112 113 114

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

Romain Courteaud's avatar
Romain Courteaud committed
115 116
  def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None, 
                                 **kw):
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
    """
      Remove workflow related to the portal type
    """
    self.getWorkflowTool().setChainForPortalTypes(
        ['Organisation'], ())
    _aq_reset()

  def stepAssociateWorkflows(self, sequence=None, sequence_list=None, **kw):
    """
      Associate workflow to the portal type
    """
    self.getWorkflowTool().setChainForPortalTypes(
        ['Organisation'], ('validation_workflow', 'edit_workflow'))
    _aq_reset()

132 133 134 135 136 137 138 139
  def stepAssociateWorkflowsExcludingEdit(self, sequence=None, sequence_list=None, **kw):
    """
      Associate workflow to the portal type
    """
    self.getWorkflowTool().setChainForPortalTypes(
        ['Organisation'], ('validation_workflow',))
    _aq_reset()

Romain Courteaud's avatar
Romain Courteaud committed
140 141 142 143 144 145 146 147 148
  def stepCreateObject(self, sequence=None, sequence_list=None, **kw):
    """
      Create a object which will be tested.
    """
    portal = self.getPortal()
    module = portal.getDefaultModule(self.object_portal_type)
    object = module.newContent(portal_type=self.object_portal_type)
    sequence.edit(
        object=object,
Romain Courteaud's avatar
Romain Courteaud committed
149 150
        current_title='',
        current_group_value=None
Romain Courteaud's avatar
Romain Courteaud committed
151 152 153 154 155 156 157 158 159 160
    )

  def stepCheckTitleValue(self, sequence=None, sequence_list=None, **kw):
    """
      Check if getTitle return a correect value
    """
    object = sequence.get('object')
    current_title = sequence.get('current_title')
    self.assertEquals(object.getTitle(), current_title)

Romain Courteaud's avatar
Romain Courteaud committed
161 162
  def stepSetDifferentTitleValueWithEdit(self, sequence=None, 
                                         sequence_list=None, **kw):
Romain Courteaud's avatar
Romain Courteaud committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
    """
      Set a different title value
    """
    object = sequence.get('object')
    current_title = sequence.get('current_title')
    new_title_value = '%s_a' % current_title
    object.edit(title=new_title_value)
    sequence.edit(
        current_title=new_title_value
    )

  def stepCheckIfActivitiesAreCreated(self, sequence=None, sequence_list=None,
                                      **kw):
    """
      Check if there is a activity in activity queue.
    """
    portal = self.getPortal()
    get_transaction().commit()
    message_list = portal.portal_activities.getMessageList()
182 183 184 185 186 187 188 189
    method_id_list = [x.method_id for x in message_list]
    # XXX FIXME: how many activities should be created normally ?
    # Sometimes it's one, sometimes 2...
    self.failUnless(len(message_list) > 0)
    self.failUnless(len(message_list) < 3)
    for method_id in method_id_list:
      self.failUnless(method_id in ["immediateReindexObject", 
                                    "recursiveImmediateReindexObject"])
Romain Courteaud's avatar
Romain Courteaud committed
190

Romain Courteaud's avatar
Romain Courteaud committed
191 192
  def stepSetSameTitleValueWithEdit(self, sequence=None, sequence_list=None, 
                                    **kw):
Romain Courteaud's avatar
Romain Courteaud committed
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
    """
      Set a different title value
    """
    object = sequence.get('object')
    object.edit(title=object.getTitle())

  def stepCheckIfMessageQueueIsEmpty(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
      Check if there is no activity in activity queue.
    """
    portal = self.getPortal()
    message_list = portal.portal_activities.getMessageList()
    self.assertEquals(len(message_list), 0)

208 209 210 211 212 213 214 215 216 217
  def stepMakeImmediateReindexObjectCrashing(self, sequence=None, sequence_list=None, **kw):
    """
      Overwrite immediateReindexObject() with a crashing method
    """
    def crashingMethod(self):
      self.ImmediateReindexObjectIsCalled()
    from Products.ERP5Type.Document.Organisation import Organisation
    Organisation.immediateReindexObject = crashingMethod
    Organisation.recursiveImmediateReindexObject = crashingMethod

Romain Courteaud's avatar
Romain Courteaud committed
218 219
  def test_01_areActivitiesWellLaunchedByPropertyEdit(self, quiet=0, 
                                                      run=run_all_test):
Romain Courteaud's avatar
Romain Courteaud committed
220
    """
221 222
      Test if setter does not call a activity if the attribute 
      value is not changed.
Romain Courteaud's avatar
Romain Courteaud committed
223 224 225
    """
    if not run: return
    sequence_list = SequenceList()
226 227 228 229
    # Test without workflows associated to the portal type
    sequence_string = '\
              RemoveWorkflowsRelated \
              CreateObject \
Romain Courteaud's avatar
Romain Courteaud committed
230
              Tic \
231
              CheckTitleValue \
232
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
233
              SetDifferentTitleValueWithEdit \
234 235 236 237
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
Romain Courteaud's avatar
Romain Courteaud committed
238
              SetSameTitleValueWithEdit \
239
              CheckTitleValue \
240
              CheckIfMessageQueueIsEmpty \
Romain Courteaud's avatar
Romain Courteaud committed
241
              SetDifferentTitleValueWithEdit \
242 243 244 245 246 247 248 249 250 251
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test with workflows associated to the portal type
    sequence_string = '\
              AssociateWorkflows \
              CreateObject \
Romain Courteaud's avatar
Romain Courteaud committed
252
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
253
              CheckTitleValue \
254
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
255
              SetDifferentTitleValueWithEdit \
Romain Courteaud's avatar
Romain Courteaud committed
256 257 258 259
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
Romain Courteaud's avatar
Romain Courteaud committed
260
              SetSameTitleValueWithEdit \
261 262 263
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
264
              CheckIfMessageQueueIsEmpty \
Romain Courteaud's avatar
Romain Courteaud committed
265
              SetDifferentTitleValueWithEdit \
Romain Courteaud's avatar
Romain Courteaud committed
266 267 268 269 270 271
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
    # Test with workflows associated to the portal type, excluding edit_workflow
    sequence_string = '\
              AssociateWorkflowsExcludingEdit \
              CreateObject \
              Tic \
              CheckTitleValue \
              MakeImmediateReindexObjectCrashing \
              SetDifferentTitleValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameTitleValueWithEdit \
              CheckIfMessageQueueIsEmpty \
              CheckTitleValue \
              SetDifferentTitleValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
Romain Courteaud's avatar
Romain Courteaud committed
294 295
    sequence_list.play(self)

Romain Courteaud's avatar
Romain Courteaud committed
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
  def stepCheckGroupValue(self, sequence=None, sequence_list=None, **kw):
    """
      Check if getTitle return a correect value
    """
    object = sequence.get('object')
    current_group_value = sequence.get('current_group_value')
    self.assertEquals(object.getGroupValue(), current_group_value)

  def stepSetDifferentGroupValueWithEdit(self, sequence=None, 
                                         sequence_list=None, **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    current_group_value = sequence.get('current_group_value')
    group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
    group2 = object.portal_categories.restrictedTraverse('group/testGroup2')
    if (current_group_value is None) or \
       (current_group_value == group2) :
      new_group_value = group1
    else:
      new_group_value = group2
#     new_group_value = '%s_a' % current_title
    object.edit(group_value=new_group_value)
    sequence.edit(
        current_group_value=new_group_value
    )

  def stepSetSameGroupValueWithEdit(self, sequence=None, sequence_list=None, 
                                    **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    object.edit(group_value=object.getGroupValue())


  def test_02_areActivitiesWellLaunchedByCategoryEdit(self, quiet=0, 
                                                      run=run_all_test):
    """
      Test if setter does not call a activity if the attribute 
      value is not changed.
    """
    if not run: return
    sequence_list = SequenceList()
    # Test without workflows associated to the portal type
    sequence_string = '\
              RemoveWorkflowsRelated \
              CreateObject \
              Tic \
              CheckGroupValue \
347
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameGroupValueWithEdit \
              CheckIfMessageQueueIsEmpty \
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test with workflows associated to the portal type
    sequence_string = '\
              AssociateWorkflows \
              CreateObject \
              Tic \
              CheckGroupValue \
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
              MakeImmediateReindexObjectCrashing \
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test with workflows associated to the portal type, excluding edit_workflow
    sequence_string = '\
              AssociateWorkflowsExcludingEdit \
              CreateObject \
              Tic \
              CheckGroupValue \
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameGroupValueWithEdit \
              CheckIfMessageQueueIsEmpty \
              SetDifferentGroupValueWithEdit \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def stepSetDifferentTitleValueWithSetter(self, sequence=None, 
                                           sequence_list=None, **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    current_title = sequence.get('current_title')
    new_title_value = '%s_a' % current_title
    object.setTitle(new_title_value)
    sequence.edit(
        current_title=new_title_value
    )

  def stepSetSameTitleValueWithSetter(self, sequence=None, 
                                      sequence_list=None, **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    object.setTitle(object.getTitle())

  def test_03_areActivitiesWellLaunchedByPropertySetter(self, quiet=0, 
                                                        run=run_all_test):
    """
      Test if setter does not call a activity if the attribute 
      value is not changed.
    """
    if not run: return
    sequence_list = SequenceList()
    # Test without workflows associated to the portal type
    sequence_string = '\
              RemoveWorkflowsRelated \
              CreateObject \
              Tic \
              CheckTitleValue \
444
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
445 446 447 448 449 450
              SetDifferentTitleValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameTitleValueWithSetter \
451 452 453
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
454 455 456 457 458 459 460 461 462 463 464 465 466 467
              CheckIfMessageQueueIsEmpty \
              SetDifferentTitleValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test with workflows associated to the portal type
    sequence_string = '\
              AssociateWorkflows \
              CreateObject \
              Tic \
              CheckTitleValue \
468
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
469 470 471 472 473 474
              SetDifferentTitleValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameTitleValueWithSetter \
475 476 477
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
              CheckIfMessageQueueIsEmpty \
              SetDifferentTitleValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckTitleValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

  def stepSetDifferentGroupValueWithSetter(self, sequence=None, 
                                           sequence_list=None, **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    current_group_value = sequence.get('current_group_value')
    group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
    group2 = object.portal_categories.restrictedTraverse('group/testGroup2')
    if (current_group_value is None) or \
       (current_group_value == group2) :
      new_group_value = group1
    else:
      new_group_value = group2
#     new_group_value = '%s_a' % current_title
    object.setGroupValue(new_group_value)
    sequence.edit(
        current_group_value=new_group_value
    )

  def stepSetSameGroupValueWithSetter(self, sequence=None, 
                                      sequence_list=None, **kw):
    """
      Set a different title value
    """
    object = sequence.get('object')
    object.setGroupValue(object.getGroupValue())

  def test_04_areActivitiesWellLaunchedByCategorySetter(self, quiet=0, 
                                                        run=run_all_test):
    """
      Test if setter does not call a activity if the attribute 
      value is not changed.
    """
    if not run: return
    sequence_list = SequenceList()
    # Test without workflows associated to the portal type
    sequence_string = '\
              RemoveWorkflowsRelated \
              CreateObject \
              Tic \
              CheckGroupValue \
530
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
531 532 533 534 535 536
              SetDifferentGroupValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameGroupValueWithSetter \
537 538 539
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553
              CheckIfMessageQueueIsEmpty \
              SetDifferentGroupValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test with workflows associated to the portal type
    sequence_string = '\
              AssociateWorkflows \
              CreateObject \
              Tic \
              CheckGroupValue \
554
              MakeImmediateReindexObjectCrashing \
Romain Courteaud's avatar
Romain Courteaud committed
555 556 557 558 559 560
              SetDifferentGroupValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              SetSameGroupValueWithSetter \
561 562 563
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
Romain Courteaud's avatar
Romain Courteaud committed
564 565 566 567 568 569 570 571 572 573
              CheckIfMessageQueueIsEmpty \
              SetDifferentGroupValueWithSetter \
              CheckIfActivitiesAreCreated \
              CheckGroupValue \
              Tic \
              CheckIfMessageQueueIsEmpty \
              '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
  def stepSetObjectNotDefinedProperty(self, sequence=None, 
                                      sequence_list=None, **kw):
    """
    Set a not defined property on the object.
    """
    object = sequence.get('object')
    object.setProperty(self.not_defined_property_id,
                       self.not_defined_property_value)

  def stepCheckNotDefinedPropertySaved(self, sequence=None, 
                                       sequence_list=None, **kw):
    """
    Check if a not defined property is stored on the object.
    """
    object = sequence.get('object')
    self.assertEquals(self.not_defined_property_value,
                      getattr(object, self.not_defined_property_id))

  def stepCheckGetNotDefinedProperty(self, sequence=None, 
                                     sequence_list=None, **kw):
    """
    Check getProperty with a not defined property.
    """
    object = sequence.get('object')
    self.assertEquals(self.not_defined_property_value,
                      object.getProperty(self.not_defined_property_id))

  def stepCheckObjectPortalType(self, sequence=None, 
                                sequence_list=None, **kw):
    """
    Check the portal type of the object.
    """
    object = sequence.get('object')
    self.assertEquals(self.object_portal_type,
                      object.getPortalType())

  def stepCreateTempObject(self, sequence=None, sequence_list=None, **kw):
    """
      Create a temp object which will be tested.
    """
    portal = self.getPortal()
    from Products.ERP5Type.Document import newTempOrganisation
    tmp_object = newTempOrganisation(portal, "a_wonderful_id")
    sequence.edit(
        object=object,
        current_title='',
        current_group_value=None
    )

  def test_05_getPropertyWithoutPropertySheet(self, quiet=0, run=run_all_test):
    """
    Test if set/getProperty work without any property sheet.
    """
    if not run: return
    sequence_list = SequenceList()
    # Test on object.
    sequence_string = '\
              CreateObject \
              SetObjectNotDefinedProperty \
              CheckNotDefinedPropertySaved \
              CheckGetNotDefinedProperty \
              '
    sequence_list.addSequenceString(sequence_string)
    # Test on temp object.
    sequence_string = '\
              CreateTempObject \
              CheckObjectPortalType \
              SetObjectNotDefinedProperty \
              CheckNotDefinedPropertySaved \
              CheckGetNotDefinedProperty \
              '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

Romain Courteaud's avatar
Romain Courteaud committed
648 649 650 651 652 653 654 655
if __name__ == '__main__':
    framework()
else:
    import unittest
    def test_suite():
        suite = unittest.TestSuite()
        suite.addTest(unittest.makeSuite(TestBase))
        return suite