Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFEditions.tests.test_CopyModifyMergeRepositoryTool.TestPolicyVersioning Class Reference
Inheritance diagram for CMFEditions.tests.test_CopyModifyMergeRepositoryTool.TestPolicyVersioning:
Inheritance graph
[legend]
Collaboration diagram for CMFEditions.tests.test_CopyModifyMergeRepositoryTool.TestPolicyVersioning:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def isFCActionInPlace
def test00_interface
def test01_remove_policy_from_type
def test02_set_policy_on_type
def test03_set_policy_types_map
def test04_add_policy
def test04_add_policy_updates
def test05_remove_policy
def test07_set_policy_defs
def test08_mutators_fail_on_invalid_input
def test09_policy_hooks
def test10_remove_policy_disables_types_first
def test11_set_policy_calls_all_hooks
def test12_set_policy_types_map_calls_all_hooks
def test13_at_auto_version_hooks
def test14_has_policy

Public Attributes

 np

Detailed Description

Definition at line 384 of file test_CopyModifyMergeRepositoryTool.py.


Member Function Documentation

Reimplemented from CMFEditions.tests.test_CopyModifyMergeRepositoryTool.TestCopyModifyMergeRepositoryToolBase.

Definition at line 386 of file test_CopyModifyMergeRepositoryTool.py.

00386 
00387     def afterSetUp(self):
00388         # define number of default policies
00389         TestCopyModifyMergeRepositoryToolBase.afterSetUp(self)
00390         self.np = len(self.portal.portal_repository.listPolicies())

def CMFEditions.tests.test_CopyModifyMergeRepositoryTool.TestPolicyVersioning.isFCActionInPlace (   self,
  object_id,
  status,
  button,
  context 
)

Definition at line 391 of file test_CopyModifyMergeRepositoryTool.py.

00391 
00392     def isFCActionInPlace(self, object_id, status, button, context):
00393         fc = getToolByName(self.portal, 'portal_form_controller')
00394         for action in fc.listFormActions(1):
00395             if (object_id == action.getObjectId() and
00396                 status == action.getStatus() and
00397                 button == action.getButton() and
00398                 context == action.getContextType()):
00399                 return True
00400         return False

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 401 of file test_CopyModifyMergeRepositoryTool.py.

00401 
00402     def test00_interface(self):
00403         portal_repository = self.portal.portal_repository
00404         # test the tools interface conformance
00405         verifyObject(IContentTypeVersionPolicySupport, portal_repository)

Definition at line 406 of file test_CopyModifyMergeRepositoryTool.py.

00406 
00407     def test01_remove_policy_from_type(self):
00408         # test that policies can be removed
00409         portal_repository = self.portal.portal_repository
00410         # Set it twice to ensure that duplicates aren't created
00411         self.failUnless(portal_repository.supportsPolicy(self.portal.doc,
00412                                                         'at_edit_autoversion'))
00413         portal_repository.removePolicyFromContentType('Document',
00414                                                         'at_edit_autoversion')
00415         self.failIf(portal_repository.supportsPolicy(self.portal.doc,
00416                                                         'at_edit_autoversion'))

Definition at line 417 of file test_CopyModifyMergeRepositoryTool.py.

00417 
00418     def test02_set_policy_on_type(self):
00419         # test that policies can be set and retrieved
00420         portal_repository = self.portal.portal_repository
00421         self.failUnless(portal_repository.supportsPolicy(self.portal.doc,
00422                                                         'at_edit_autoversion'))
00423         portal_repository.removePolicyFromContentType('Document',
00424                                                         'at_edit_autoversion')
00425         self.failIf(portal_repository.supportsPolicy(self.portal.doc,
00426                                                         'at_edit_autoversion'))
00427         portal_repository.addPolicyForContentType('Document',
00428                                                         'at_edit_autoversion')
00429         self.failUnless(portal_repository.supportsPolicy(self.portal.doc,
00430                                                         'at_edit_autoversion'))

Definition at line 431 of file test_CopyModifyMergeRepositoryTool.py.

00431 
00432     def test03_set_policy_types_map(self):
00433         # test the mapping of policies to types
00434         portal_repository = self.portal.portal_repository
00435         # Get something in place first
00436         portal_repository.addPolicyForContentType('Document',
00437                                                         'at_edit_autoversion')
00438         portal_repository.removePolicyFromContentType('Document',
00439                                                         'at_edit_autoversion')
00440         # update the mapping
00441         portal_repository.manage_setTypePolicies({'Document':
00442                                                      ['at_edit_autoversion']})
00443         self.failUnless(portal_repository.supportsPolicy(self.portal.doc,
00444                                                        'at_edit_autoversion'))

Definition at line 445 of file test_CopyModifyMergeRepositoryTool.py.

00445 
00446     def test04_add_policy(self):
00447         # test adding a new policy
00448         portal_repository = self.portal.portal_repository
00449         self.assertEqual(len(portal_repository.listPolicies()), self.np)
00450         portal_repository.addPolicy('version_on_publish',
00451                                             'Create version when published')
00452         policies = portal_repository.listPolicies()
00453         self.assertEqual(len(policies), self.np+1)
00454         self.failUnless('version_on_publish' in [p.getId() for p in policies])

Definition at line 455 of file test_CopyModifyMergeRepositoryTool.py.

00455 
00456     def test04_add_policy_updates(self):
00457         # test calling addPolicy with an existing Id updates the title
00458         portal_repository = self.portal.portal_repository
00459         self.assertEqual(len(portal_repository.listPolicies()), self.np)
00460         portal_repository.addPolicy('at_edit_autoversion',
00461                                             'Fake policy title')
00462         policies = portal_repository.listPolicies()
00463         self.assertEqual(len(policies), self.np)
00464         self.failUnless('Fake policy title' in [p.Title() for p in policies])

Definition at line 465 of file test_CopyModifyMergeRepositoryTool.py.

00465 
00466     def test05_remove_policy(self):
00467         # test removing a policy removes the policy from all content types
00468         portal_repository = self.portal.portal_repository
00469         portal_repository.addPolicy('version_on_publish',
00470                                             'Create version when published')
00471         portal_repository.addPolicyForContentType('Document',
00472                                                         'version_on_publish')
00473         portal_repository.removePolicy('version_on_publish')
00474         self.assertEqual(len(portal_repository.listPolicies()), self.np)
00475         self.failIf(portal_repository.supportsPolicy(self.portal.doc,
00476                                                         'version_on_publish'))

Definition at line 477 of file test_CopyModifyMergeRepositoryTool.py.

00477 
00478     def test07_set_policy_defs(self):
00479         # test update policy definition list
00480         portal_repository = self.portal.portal_repository
00481         portal_repository.removePolicy('at_edit_autoversion')
00482         self.assertEqual(len(portal_repository.listPolicies()), self.np-1)
00483         portal_repository.manage_changePolicyDefs((('at_edit_autoversion',
00484                                             'Fake policy title'),))
00485         policies = portal_repository.listPolicies()
00486         self.assertEqual(len(policies), 1)
00487         self.failUnless('Fake policy title' in [p.Title() for p in policies])

Definition at line 488 of file test_CopyModifyMergeRepositoryTool.py.

00488 
00489     def test08_mutators_fail_on_invalid_input(self):
00490         portal_repository = self.portal.portal_repository
00491         # manage_changePolicyDefs requires a sequence of two-tuples with
00492         # strings
00493         self.assertRaises(AssertionError,
00494                             portal_repository.manage_changePolicyDefs,
00495                             {'at_edit_autoversion':'Fake policy title'})
00496         self.assertRaises(AssertionError,
00497                             portal_repository.manage_changePolicyDefs,
00498                             ('at_edit_autoversion','policy2'))
00499         self.assertRaises(AssertionError,
00500                             portal_repository.manage_changePolicyDefs,
00501                             [(1,'My new policy')])
00502         self.assertRaises(TypeError,
00503                             portal_repository.manage_changePolicyDefs,
00504                 [('at_edit_autoversion','My new policy', 'some_extra_stuff')])
00505         self.assertRaises(AssertionError,
00506                             portal_repository.manage_changePolicyDefs,
00507         [('at_edit_autoversion','My new policy', dummyPolicyWithHooks,'str')])
00508         # manage_setTypePolicies requires a mapping of of portal_types to a
00509         # list of valid policies
00510         self.assertRaises(AssertionError,
00511                             portal_repository.manage_setTypePolicies,
00512                             {'my_type':'at_edit_autoversion'})
00513         self.assertRaises(AssertionError,
00514                             portal_repository.manage_setTypePolicies,
00515                             {'my_type':['a_bogus_policy']})
00516         self.assertRaises(AssertionError,
00517                             portal_repository.manage_setTypePolicies,
00518                             (('my_type',['a_bogus_policy']),))
00519         # addPolicyForContentType fails unless the policy is valid
00520         self.assertRaises(AssertionError,
00521                             portal_repository.addPolicyForContentType,
00522                             'my_type','my_bogus_policy')

Definition at line 523 of file test_CopyModifyMergeRepositoryTool.py.

00523 
00524     def test09_policy_hooks(self):
00525         portal_repository = self.portal.portal_repository
00526         out = []
00527         # Test hooks on basic actions
00528         portal_repository.addPolicy('my_bogus_policy',
00529                                   'Hook Tests', dummyPolicyWithHooks, out=out)
00530         self.assertEqual(out, ['added'])
00531         self.assertEqual(len(portal_repository.listPolicies()), self.np+1)
00532         portal_repository.addPolicyForContentType('Document',
00533                                                    'my_bogus_policy', out=out)
00534         self.failUnless(portal_repository.supportsPolicy(self.portal.doc,
00535                                                         'my_bogus_policy'))
00536         self.assertEqual(out, ['added','enabled Document'])
00537         portal_repository.removePolicyFromContentType('Document',
00538                                                    'my_bogus_policy', out=out)
00539         self.failIf(portal_repository.supportsPolicy(self.portal.doc,
00540                                                         'my_bogus_policy'))
00541         self.assertEqual(out, ['added','enabled Document',
00542                                                     'disabled Document'])
00543         portal_repository.removePolicy('my_bogus_policy', out=out)
00544         self.assertEqual(out, ['added','enabled Document',
00545                                             'disabled Document','removed'])
00546         self.assertEqual(len(portal_repository.listPolicies()), self.np)

Definition at line 547 of file test_CopyModifyMergeRepositoryTool.py.

00547 
00548     def test10_remove_policy_disables_types_first(self):
00549         # Ensure that removal calls the type removal hooks
00550         portal_repository = self.portal.portal_repository
00551         out = []
00552         portal_repository.addPolicy('my_bogus_policy',
00553                                   'Hook Tests', dummyPolicyWithHooks, out=out)
00554         portal_repository.addPolicyForContentType('Document',
00555                                                    'my_bogus_policy', out=out)
00556         portal_repository.removePolicy('my_bogus_policy', out=out)
00557         self.assertEqual(out, ['added','enabled Document',
00558                                             'disabled Document','removed'])

Definition at line 559 of file test_CopyModifyMergeRepositoryTool.py.

00559 
00560     def test11_set_policy_calls_all_hooks(self):
00561         # Explicitly setting policies removes/disables all old policies and
00562         # adds/enables new ones.
00563         portal_repository = self.portal.portal_repository
00564         out = []
00565         portal_repository.addPolicy('my_bogus_policy',
00566                                   'Hook Tests', dummyPolicyWithHooks, out=out)
00567         portal_repository.addPolicyForContentType('Document',
00568                                                    'my_bogus_policy', out=out)
00569         portal_repository.manage_changePolicyDefs((('my_bogus_policy2',
00570                   'Fake title', dummyPolicyWithHooks, {'out':out}),), out=out)
00571         self.assertEqual(out, ['added','enabled Document','disabled Document',
00572                     'removed','added'])

Definition at line 573 of file test_CopyModifyMergeRepositoryTool.py.

00573 
00574     def test12_set_policy_types_map_calls_all_hooks(self):
00575         # Explicitly setting policies removes/disables all old policies and
00576         # adds/enables new ones.
00577         portal_repository = self.portal.portal_repository
00578         out = []
00579         portal_repository.addPolicy('my_bogus_policy',
00580                                   'Hook Tests', dummyPolicyWithHooks, out=out)
00581         portal_repository.addPolicyForContentType('Document',
00582                                                    'my_bogus_policy', out=out)
00583         portal_repository.manage_setTypePolicies({'Event':
00584                                                          ['my_bogus_policy']},
00585                                                          out=out)
00586         self.assertEqual(out, ['added','enabled Document','disabled Document',
00587                     'enabled Event'])

Definition at line 588 of file test_CopyModifyMergeRepositoryTool.py.

00588 
00589     def test13_at_auto_version_hooks(self):
00590         portal_repository = self.portal.portal_repository
00591         # Check if the form controller hook is in place:
00592         self.failUnless(self.isFCActionInPlace('validate_integrity',
00593                                                      'success', None, None))
00594         self.failUnless(self.isFCActionInPlace('atct_edit',
00595                                                      'success', None, None))
00596         # Remove policy and check if hook is removed
00597         portal_repository.removePolicy('at_edit_autoversion')
00598         self.failIf(self.isFCActionInPlace('validate_integrity',
00599                                                  'success', None, None))
00600         self.failIf(self.isFCActionInPlace('atct_edit',
00601                                                      'success', None, None))
00602         # Add policy and check if hook is added
00603         portal_repository.addPolicy('at_edit_autoversion', 'Auto policy',
00604                                      ATVersionOnEditPolicy)
00605         self.failUnless(self.isFCActionInPlace('validate_integrity',
00606                                                      'success', None, None))
00607         self.failUnless(self.isFCActionInPlace('atct_edit',
00608                                                      'success', None, None))

Here is the call graph for this function:

Definition at line 609 of file test_CopyModifyMergeRepositoryTool.py.

00609 
00610     def test14_has_policy(self):
00611         portal_repository = self.portal.portal_repository
00612         # We already have two policies by default
00613         self.failUnless(portal_repository.hasPolicy(self.portal.doc))
00614         portal_repository.removePolicyFromContentType('Document',
00615                                                         'at_edit_autoversion')
00616         portal_repository.removePolicyFromContentType('Document',
00617                                                         'version_on_revert')
00618         self.failIf(portal_repository.hasPolicy(self.portal.doc))
00619 
00620 


Member Data Documentation

Definition at line 389 of file test_CopyModifyMergeRepositoryTool.py.


The documentation for this class was generated from the following file: