Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
plone.app.contentrules.tests.test_configuration.TestGenericSetup Class Reference
Inheritance diagram for plone.app.contentrules.tests.test_configuration.TestGenericSetup:
Inheritance graph
[legend]
Collaboration diagram for plone.app.contentrules.tests.test_configuration.TestGenericSetup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testRuleInstalled
def testRulesConfigured
def testRuleAssigned
def testAssignmentOrdering
def testImportTwice
def testExport

Public Attributes

 storage

Static Public Attributes

 layer = TestContentrulesGSLayer

Detailed Description

Definition at line 71 of file test_configuration.py.


Member Function Documentation

Definition at line 75 of file test_configuration.py.

00075 
00076     def afterSetUp(self):
00077         self.storage = getUtility(IRuleStorage)
    

Definition at line 129 of file test_configuration.py.

00129 
00130     def testAssignmentOrdering(self):
00131         assignable = IRuleAssignmentManager(self.portal.news)
00132         self.assertEquals([u'test3', u'test2', u'test1'], assignable.keys())
        

Definition at line 145 of file test_configuration.py.

00145 
00146     def testExport(self):
00147         site = self.portal
00148         context = TarballExportContext(self.portal.portal_setup)
00149         exporter = getMultiAdapter((site, context), IBody, name=u'plone.contentrules')
00150         
00151         expected = """\
00152 <?xml version="1.0"?>
00153 <contentrules>
00154  <rule name="test1" title="Test rule 1" description="A test rule"
00155     enabled="True" event="zope.lifecycleevent.interfaces.IObjectModifiedEvent"
00156     stop-after="False">
00157   <conditions>
00158    <condition type="plone.conditions.PortalType">
00159     <property name="check_types">
00160      <element>Document</element>
00161      <element>News Item</element>
00162     </property>
00163    </condition>
00164    <condition type="plone.conditions.Role">
00165     <property name="role_names">
00166      <element>Manager</element>
00167     </property>
00168    </condition>
00169   </conditions>
00170   <actions>
00171    <action type="plone.actions.Notify">
00172     <property name="message">A message: Hej då</property>
00173     <property name="message_type">info</property>
00174    </action>
00175   </actions>
00176  </rule>
00177  <rule name="test2" title="Test rule 2" description="Another test rule"
00178     enabled="False"
00179     event="zope.lifecycleevent.interfaces.IObjectModifiedEvent"
00180     stop-after="True">
00181   <conditions>
00182    <condition type="plone.conditions.PortalType">
00183     <property name="check_types">
00184      <element>Event</element>
00185     </property>
00186    </condition>
00187   </conditions>
00188   <actions>
00189    <action type="plone.actions.Workflow">
00190     <property name="transition">publish</property>
00191    </action>
00192   </actions>
00193  </rule>
00194  <rule name="test3" title="Test rule 3" description="Third test rule"
00195     enabled="True" event="zope.app.container.interfaces.IObjectMovedEvent"
00196     stop-after="False">
00197   <conditions/>
00198   <actions/>
00199  </rule>
00200  <assignment name="test3" bubbles="False" enabled="False" location="/news"/>
00201  <assignment name="test2" bubbles="True" enabled="False" location="/news"/>
00202  <assignment name="test1" bubbles="False" enabled="True" location="/news"/>
00203 </contentrules>
00204 """
00205 
00206         body = exporter.body
00207         self.assertEquals(expected.strip(), body.strip(), body)
        

Here is the call graph for this function:

Definition at line 133 of file test_configuration.py.

00133 
00134     def testImportTwice(self):
00135         # Ensure rules, actions/conditions and assignments are not duplicated
00136         # if the profile is re-imported; see bug #8027.
00137         portal_setup = self.portal.portal_setup
00138         time.sleep(1) # avoid timestamp colission
00139         portal_setup.runAllImportStepsFromProfile('profile-plone.app.contentrules:testing')
00140         
00141         # We should get the same results as before
00142         self.testRuleInstalled()
00143         self.testRulesConfigured()
00144         self.testRuleAssigned()
        

Here is the call graph for this function:

Definition at line 116 of file test_configuration.py.

00116 
00117     def testRuleAssigned(self):
00118         assignable = IRuleAssignmentManager(self.portal.news)
00119         self.assertEquals(3, len(assignable))
00120         
00121         self.assertEquals(True, assignable['test1'].enabled)
00122         self.assertEquals(False, assignable['test1'].bubbles)
00123         
00124         self.assertEquals(False, assignable['test2'].enabled)
00125         self.assertEquals(True, assignable['test2'].bubbles)
00126         
00127         self.assertEquals(False, assignable['test3'].enabled)
00128         self.assertEquals(False, assignable['test3'].bubbles)
        

Here is the caller graph for this function:

Definition at line 78 of file test_configuration.py.

00078 
00079     def testRuleInstalled(self):
00080         self.failUnless('test1' in self.storage)
00081         self.failUnless('test2' in self.storage)
        

Here is the caller graph for this function:

Definition at line 82 of file test_configuration.py.

00082 
00083     def testRulesConfigured(self):
00084         rule1 = self.storage['test1']
00085         self.assertEquals("Test rule 1", rule1.title)
00086         self.assertEquals("A test rule", rule1.description)
00087         self.assertEquals(IObjectModifiedEvent, rule1.event)
00088         self.assertEquals(True, rule1.enabled)
00089         self.assertEquals(False, rule1.stop)
00090         
00091         self.assertEquals(2, len(rule1.conditions))
00092         self.assertEquals("plone.conditions.PortalType", rule1.conditions[0].element)
00093         self.assertEquals(["Document", "News Item"], list(rule1.conditions[0].check_types))
00094         self.assertEquals("plone.conditions.Role", rule1.conditions[1].element)
00095         self.assertEquals(["Manager"], list(rule1.conditions[1].role_names))
00096         
00097         self.assertEquals(1, len(rule1.actions))
00098         self.assertEquals("plone.actions.Notify", rule1.actions[0].element)
00099         self.assertEquals(u"A message: Hej d\xe5", rule1.actions[0].message)
00100         self.assertEquals("info", rule1.actions[0].message_type)
00101         
00102         rule2 = self.storage['test2']
00103         self.assertEquals("Test rule 2", rule2.title)
00104         self.assertEquals("Another test rule", rule2.description)
00105         self.assertEquals(IObjectModifiedEvent, rule2.event)
00106         self.assertEquals(False, rule2.enabled)
00107         self.assertEquals(True, rule2.stop)
00108         
00109         self.assertEquals(1, len(rule2.conditions))
00110         self.assertEquals("plone.conditions.PortalType", rule2.conditions[0].element)
00111         self.assertEquals(["Event"], list(rule2.conditions[0].check_types))
00112         
00113         self.assertEquals(1, len(rule2.actions))
00114         self.assertEquals("plone.actions.Workflow", rule2.actions[0].element)
00115         self.assertEquals("publish", rule2.actions[0].transition)
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 73 of file test_configuration.py.

Definition at line 76 of file test_configuration.py.


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