testResourceVariation.py 29.5 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 54 55 56 57 58 59 60 61 62 63 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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
#############################################################################
#
# Copyright (c) 2007 Nexedi SA and Contributors. All Rights Reserved.
#                    Daniel Feliubadalo  <daniel@sip2000.com>
#                    Romain Courteaud  <romain@nexedi.com>
#                    Alexandre Boeglin  <alex@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.
#
##############################################################################

"""
Tests Resource Variations
"""
import unittest
from Testing import ZopeTestCase
from zLOG import LOG
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from AccessControl.SecurityManagement import newSecurityManager

class ResourceVariationTestCase(ERP5TypeTestCase):
  """Tests starts with a preference activated for self.my_organisation, logged in
  as a user with Manager role.

  All documents created appart from this configuration will be deleted in
  teardown. So users of this test case are encouraged to create new documents
  rather than modifying default documents.
  """
  def logMessage(self, msg, tab=0):
    """
    Log a message.
    """
    if tab:
      msg = '  %s' % msg
    ZopeTestCase._print('\n%s' % msg)
    LOG('testResource.play', 0, msg)

  def _doWorkflowAction(self, ob, action, **kw):
    self.portal.portal_workflow.doActionFor(ob, action,
                                            comment = 'for unit test',**kw)

  @reindex
  def _makeOneResource(self, portal_type='Product',
                       validation_state='draft', **kw):
    """
    Creates an resource

    The default settings is for self.section.
    You can pass a list of mapping as lines, then lines will be created
    using this information.
    """
    rs = self.portal.getDefaultModule(portal_type).newContent(
                              portal_type=portal_type,**kw)

    if validation_state == 'validated':
      rs.validate()
    return rs

  @reindex
  def _makeOneResourceIndividualVariation(self, resource, **kw):
    """
    Creates a Individual variation sub object, and edit it with kw.
    """
    iv = resource.newContent(portal_type='%s Individual Variation' % \
                              resource.getPortalType(), **kw)
    return iv

  def afterSetUp(self):
    """
    - create categories
    - create preference
    - make sure categories are included to portal types
    """
    self.portal = self.getPortal()
    self.portal_categories = self.portal.portal_categories
    self.portal_preferences = self.portal.portal_preferences
    self.product_module = self.portal.product_module
    self.service_module = self.portal.service_module
    self.component_module = self.portal.component_module

    # create variation categories
    category_type=('line', 'variation')
    if not self.portal_categories.hasContent('required_size'):
      size = self.portal_categories.newContent(portal_type='Base Category',
                                title='Required Size',
                                reference='required_size',
                                id='required_size',
                                category_type=category_type)
    else:
      size = self.portal_categories['required_size']

    size.newContent(portal_type='Category', title='Large',
                    reference='l',id='l')
    size.newContent(portal_type='Category', title='Medium',
                    reference='l',id='m')
    size.newContent(portal_type='Category', title='Small',
                    reference='l',id='s')
    size.newContent(portal_type='Category', title='XL',
                    reference='l',id='xl')
    size.newContent(portal_type='Category', title='XXL',
                    reference='l',id='xxl')

    if not self.portal_categories.hasContent('option_colour'):
      colour = self.portal_categories.newContent(portal_type='Base Category',
                                title='Optional Colour',
                                reference='option_colour',
                                id='option_colour',
                                category_type=category_type)
    else:
      colour = self.portal_categories['option_colour']

    colour.newContent(portal_type='Category', title='Blue',
                      reference='l',id='blue')
    colour.newContent(portal_type='Category', title='Green',
                      reference='l',id='green')
    colour.newContent(portal_type='Category', title='Red',
                      reference='l',id='red')

    if not self.portal_categories.hasContent('individual_aspect'):
      aspect = self.portal_categories.newContent(portal_type='Base Category',
                                title='Individual Aspect',
                                reference='individual_aspect',
                                id='individual_aspect',
                                category_type=category_type)

    aspect.newContent(portal_type='Category', title='Aspect 1',
                      reference='A1',id='a1')
    aspect.newContent(portal_type='Category', title='Aspect 2',
                      reference='A2',id='a2')

    #create resource variation preferences
152 153
    preference = getattr(self.portal_preferences, 'test_site_preference', None)
    if preference is None:
154 155 156 157 158 159
      preference = self.portal_preferences.newContent(portal_type='Preference',
                                title='Default Site Preference',
                                id='test_site_preference')
      preference.enable()

    value='individual_aspect'
160 161 162
    preference.setPreferredProductIndividualVariationBaseCategory(value)
    preference.setPreferredServiceIndividualVariationBaseCategory(value)
    preference.setPreferredComponentIndividualVariationBaseCategory(value)
163 164

    value=('required_size',)
165 166 167
    preference.setPreferredProductVariationBaseCategoryList(value)
    preference.setPreferredServiceVariationBaseCategoryList(value)
    preference.setPreferredComponentVariationBaseCategoryList(value)
168 169

    value=('option_colour',)
170 171 172 173
    preference.setPreferredProductOptionalVariationBaseCategory(value)
    preference.setPreferredServiceOptionalVariationBaseCategory(value)
    preference.setPreferredComponentOptionalVariationBaseCategory(value)

174 175 176 177
    # all this available to catalog

    #adding to base categories of resources
    #for use setRequiredSizeList and setOptionColourList methods
178
    self.portal.portal_types['Product']._setTypeBaseCategoryList([
179 180
                                            'required_size',
                                            'option_colour',
181 182
                                            'individual_aspect'])
    self.portal.portal_types['Service']._setTypeBaseCategoryList([
183 184
                                            'required_size',
                                            'option_colour',
185 186
                                            'individual_aspect'])
    self.portal.portal_types['Component']._setTypeBaseCategoryList([
187 188
                                            'required_size',
                                            'option_colour',
189
                                            'individual_aspect'])
190 191 192 193 194
    self.tic()

  def beforeTearDown(self):
    """Remove all documents.
    """
195
    self.abort()
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 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 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 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 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 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 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
    self.product_module.manage_delObjects(
                      list(self.service_module.objectIds()))
    self.service_module.manage_delObjects(
                      list(self.service_module.objectIds()))
    self.component_module.manage_delObjects(
                      list(self.component_module.objectIds()))
    self.portal_categories.manage_delObjects((['required_size',
                                    'individual_aspect','option_colour']))

    self.tic()

  def getBusinessTemplateList(self):
    """Returns list of BT to be installed."""
    return ('erp5_base', 'erp5_pdm')
  
  def _testResourceDefaultConfig(self,resource):
    """
    Check variation API when creating a default resource.
    This should use what is defined in preferences.
    """
    # XXX Check default config
    self.assertSameSet(['required_size', 
                        'option_colour', 
                        'individual_aspect'],
                        resource.getVariationBaseCategoryList())
                        
    self.assertSameSet(['required_size/l',
                        'required_size/m', 
                        'required_size/s', 
                        'required_size/xl', 
                        'required_size/xxl', 
                        'individual_aspect/a1', 
                        'individual_aspect/a2', 
                        'option_colour/blue', 
                        'option_colour/green', 
                        'option_colour/red'], 
                        resource.getVariationRangeCategoryList())
                        
    self.assertSameSet([], resource.getVariationCategoryList())
    
  def _testResourceWithoutVariation(self,resource):
    """
    Check variation API when creating a resource and removing its variation
    axes
    """
    resource.edit(variation_base_category_list=[],
                  optional_variation_base_category_list=[],
                  individual_variation_base_category_list=[])

    self.assertSameSet([], resource.getVariationBaseCategoryList())
    self.assertSameSet([], resource.getVariationRangeCategoryList())
    self.assertSameSet([], resource.getVariationCategoryList())

    # XXX What happens when we create an individual variation
    resource_circular = self._makeOneResourceIndividualVariation(
              resource,
              id='1',
              title='Circular')

    self.assertSameSet([], resource.getVariationBaseCategoryList())
    self.assertSameSet([], resource.getVariationRangeCategoryList())
    self.assertSameSet([], resource.getVariationCategoryList())

  def _testResourceCategoryVariation(self,resource):
    """
    Check variation API when defining only category as variation
    axes
    """
    # Define variations
    resource.setRequiredSizeList(['l', 'm','s'])

    resource.setOptionColourList(['blue'])

    self.assertSameSet(['required_size','option_colour','individual_aspect'],
                       resource.getVariationBaseCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'option_colour/blue'],
                       resource.getVariationCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/a1',
                        'individual_aspect/a2'],
                        resource.getVariationRangeCategoryList())

    # Now, define aspect categories, which should not be used as variation
    resource.setIndividualAspectList(['a1'])

    self.assertSameSet(['required_size','option_colour','individual_aspect'],
                       resource.getVariationBaseCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'option_colour/blue'],
                       resource.getVariationCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/a1',
                        'individual_aspect/a2'],
                       resource.getVariationRangeCategoryList())

  def _testResourceIndividualVariation(self,resource):
    """
    Check variation API when defining individual variation
    """
    # Creating individual variations of resource
    resource_iv1 = self._makeOneResourceIndividualVariation(resource,
              id='1',
              title='Circular',
    )

    resource_iv2 = self._makeOneResourceIndividualVariation(resource,
              id='2',
              title='Triangular',
    )

    resource_iv3 = self._makeOneResourceIndividualVariation(resource,
              id='3',
              title='Square',
    )
    # Check default parameter
    self.assertSameSet([],
                       resource.getVariationCategoryList())
    self.assertSameSet(['individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                        resource.getVariationCategoryList(
                                omit_individual_variation=0))
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                        resource.getVariationRangeCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                        resource.getVariationRangeCategoryList(
                                omit_individual_variation=0))

    # Now, define aspect categories, which should not be used as variation
    resource.setIndividualAspectList(['a1'])

    # Check default parameter
    self.assertSameSet([],
                       resource.getVariationCategoryList())
    self.assertSameSet(['individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                       resource.getVariationCategoryList(
                                omit_individual_variation=0))
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                       resource.getVariationRangeCategoryList())
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                       resource.getVariationRangeCategoryList(
                                omit_individual_variation=0))

  def _testResourceVariation(self,resource):
    """
    Combine individual and category variations
    """
    resource.setRequiredSizeList(['l', 'm', 's'])

    resource.setOptionColourList(['blue'])

    # creating individual variations of resource
    resource_iv1=self._makeOneResourceIndividualVariation(resource,
              id='1',
              title='Circular',
    )

    resource_iv2=self._makeOneResourceIndividualVariation(resource,
              id='2',
              title='Triangular',
    )

    resource_iv3=self._makeOneResourceIndividualVariation(resource,
              id='3',
              title='Square',
    )

    self.assertSameSet(['option_colour',],
                             resource.getOptionalVariationBaseCategoryList())

    self.assertSameSet(['individual_aspect',],
                             resource.getIndividualVariationBaseCategoryList())

    # Check default parameters
    self.assertSameSet(['required_size','option_colour','individual_aspect'],
                             resource.getVariationBaseCategoryList())

    self.assertSameSet(['required_size','option_colour','individual_aspect'],
                             resource.getVariationBaseCategoryList(
                                         omit_individual_variation=0,
                                         omit_optional_variation=0))

    self.assertSameSet(['required_size','option_colour'],
                             resource.getVariationBaseCategoryList(
                                         omit_individual_variation=1,
                                         omit_optional_variation=0))

    self.assertSameSet(['required_size',],
                             resource.getVariationBaseCategoryList(
                                         omit_individual_variation=1,
                                         omit_optional_variation=1))

    # Check default parameters
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'option_colour/blue'],
                             resource.getVariationCategoryList())

    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'option_colour/blue',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                             resource.getVariationCategoryList(
                                         omit_individual_variation=0))

    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'option_colour/blue'],
                             resource.getVariationCategoryList(
                                         omit_individual_variation=1))

    # Check default parameters
    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                             resource.getVariationRangeCategoryList())

    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red',
                        'individual_aspect/'+resource_iv1.getRelativeUrl(),
                        'individual_aspect/'+resource_iv2.getRelativeUrl(),
                        'individual_aspect/'+resource_iv3.getRelativeUrl()],
                             resource.getVariationRangeCategoryList(
                                         omit_individual_variation=0))

    self.assertSameSet(['required_size/l',
                        'required_size/m',
                        'required_size/s',
                        'required_size/xl',
                        'required_size/xxl',
                        'option_colour/blue',
                        'option_colour/green',
                        'option_colour/red'],
                            resource.getVariationRangeCategoryList(
                                         omit_individual_variation=1))

class TestResourceVariation(ResourceVariationTestCase):
  """
  Test Resource Variation

  Test basic cases of gathering data to render forms, the purpose of those
  tests is to exercise basic variation results.
  """
  def getTitle(self):
    return "Resource Variations"

  def testResourceDefaultConfig(self):
    """
    Check variation API when creating a default resource.
    This should use what is defined in preferences.
    """
    self.logMessage('testResourceDefaultConfig')
    # Create Product
    product = self._makeOneResource(
              id='1',
              portal_type='Product',
              title='Product One',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceDefaultConfig(product)
    # Create Service
    service = self._makeOneResource(
              id='1',
              portal_type='Service',
              title='Service One',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceDefaultConfig(service)
    # Create Component
    component = self._makeOneResource(
              id='1',
              portal_type='Component',
              title='Component One',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceDefaultConfig(component)

  def testResourceWithoutVariation(self):
    """
    Check variation API when creating a resource and removing its variation
    axes
    """
    self.logMessage('testResourceWithoutVariation')
    # Create Product
    product = self._makeOneResource(
              id='2',
              portal_type='Product',
              title='Product Two',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceWithoutVariation(product)
    # Create Service
    service = self._makeOneResource(
              id='2',
              portal_type='Service',
              title='Service Two',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceWithoutVariation(service)
    # Create Component
    component = self._makeOneResource(
              id='2',
              portal_type='Component',
              title='Component Two',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceWithoutVariation(component)

  def testResourceCategoryVariation(self):
    """
    Check variation API when defining only category as variation
    axes
    """
    self.logMessage('testResourceCategoryVariation')
    # Create Product
    product = self._makeOneResource(
              id='3',
              portal_type='Product',
              title='Product Three',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceCategoryVariation(product)
    # Create Service
    service = self._makeOneResource(
              id='3',
              portal_type='Service',
              title='Service Three',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceCategoryVariation(service)
    # Create Component
    component = self._makeOneResource(
              id='3',
              portal_type='Component',
              title='Component Three',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceCategoryVariation(component)

  def testResourceIndividualVariation(self):
    """
    Check variation API when defining individual variation
    """
    self.logMessage('testResourceIndividualVariation')
    # Create Product
    product = self._makeOneResource(
              id='4',
              portal_type='Product',
              title='Product Four',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceIndividualVariation(product)
    # Create Service
    service = self._makeOneResource(
              id='4',
              portal_type='Service',
              title='Service Four',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceIndividualVariation(service)
    # Create Component
    component = self._makeOneResource(
              id='4',
              portal_type='Component',
              title='Component Four',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceIndividualVariation(component)

  def testResourceVariation(self):
    """
    Combine individual and category variations
    """
    # Resource Variation test.
    self.logMessage('testResourceVariation')
    # Create Product
    product = self._makeOneResource(
              id='5',
              portal_type='Product',
              title='Product Five',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceVariation(product)
    # Create Service
    service = self._makeOneResource(
              id='5',
              portal_type='Service',
              title='Service Five',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceVariation(service)
    # Create Component
    component = self._makeOneResource(
              id='5',
              portal_type='Component',
              title='Component Five',
              validation_state='validated',
              variation_base_category='required_size',
              optional_variation_base_category='option_colour',
              individual_variation_base_category='individual_aspect')
    self._testResourceVariation(component)
              
def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestResourceVariation))
  return suite