[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py A functional test for ContentWorklowsManager.

Eckart Hertzler eckart at hertzler.de
Mon May 17 05:50:47 EDT 2004


Log message for revision 24767:
A functional test for ContentWorklowsManager.

- test adding of ContentWorkflowManager 
- test content mapping registry



-=-
Added: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py	2004-05-17 09:49:11 UTC (rev 24766)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py	2004-05-17 09:50:47 UTC (rev 24767)
@@ -0,0 +1,154 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Functional Tests for StatefulProcessDefinition
+
+   $Id$
+   
+"""
+import unittest
+import re
+
+from zope.interface import Interface
+from zope.app.component.interface import nameToInterface
+from zope.app import zapi
+from zope.app.tests.functional import BrowserTestCase
+from zope.app.registration.interfaces import ActiveStatus
+from zope.app.utility.utility import LocalUtilityService
+from zope.app.utility.utility import UtilityRegistration
+from zope.app.traversing import getPath, traverse
+
+from zope.app.workflow.stateful.definition import StatefulProcessDefinition
+from zope.app.workflow.stateful.interfaces import IStatefulProcessDefinition,\
+     IContentWorkflowsManager
+
+class Test(BrowserTestCase):
+
+    def setUp(self):
+        BrowserTestCase.setUp(self)
+        self.basepath = '/++etc++site/default'
+        root = self.getRootFolder()
+        default = zapi.traverse(root, '/++etc++site/default')
+        rm = default.getRegistrationManager()
+
+        default['pd'] = StatefulProcessDefinition()
+        pd_path = getPath(default['pd'])
+        registration = UtilityRegistration(
+            'dummy-definition', IStatefulProcessDefinition, pd_path)
+        pd_id = rm.addRegistration(registration)
+        traverse(rm, pd_id).status = ActiveStatus
+
+        self.basepath = '/++etc++site/default'
+        response = self.publish(
+            self.basepath + '/contents.html',
+            basic='mgr:mgrpw')
+        
+        self.assertEqual(response.getStatus(), 200)
+        
+        expr = 'zope.app.browser.add.ContentWorkflowsManager.f([0-9]*)'
+        m = re.search(expr, response.getBody())
+        type_name = m.group(0)
+        
+        response = self.publish(
+            self.basepath + '/contents.html',
+            basic='mgr:mgrpw',
+            form={'type_name': type_name,
+                  'new_value': 'mgr' })
+
+        root = self.getRootFolder()
+        mgr = zapi.traverse(root, self.basepath+'/mgr')
+        registration = UtilityRegistration(
+            'cwm', IContentWorkflowsManager, self.basepath+'/mgr')
+        pd_id = rm.addRegistration(registration)
+        traverse(rm, pd_id).status = ActiveStatus
+        
+
+    def test_subscribe(self):
+        response = self.publish(
+            self.basepath + '/mgr/index.html',
+            basic='mgr:mgrpw')
+        
+        self.assertEqual(response.getStatus(), 200)
+        body = ' '.join(response.getBody().split())
+        self.assert_(body.find("Subscription state: OFF") >= 0)        
+
+        response = self.publish(
+            self.basepath + '/mgr/index.html',
+            basic='mgr:mgrpw',
+            form={'callSubscribe':'Subscribe'})
+        
+        self.assertEqual(response.getStatus(), 200)
+        body = ' '.join(response.getBody().split())
+        self.assert_(body.find("Subscription state: ON") >= 0)        
+        root = self.getRootFolder()
+        mgr = zapi.traverse(root, self.basepath+'/mgr')
+        self.assert_(mgr.isSubscribed())
+        
+    def test_registry(self):
+        response = self.publish(
+            self.basepath + '/mgr/registry.html',
+            basic='mgr:mgrpw')
+        
+        self.assertEqual(response.getStatus(), 200)
+        body = ' '.join(response.getBody().split())
+        self.assert_(body.find(
+            '<option value="zope.app.workflow.stateful.interfaces.IState">'
+            ) >= 0)        
+        self.assert_(body.find(
+            '<option value="zope.app.workflow.stateful.interfaces.ITransition">'
+            ) >= 0)        
+
+        response = self.publish(
+            self.basepath + '/mgr/registry.html',
+            basic='mgr:mgrpw',
+            form={
+            'field.iface':['zope.app.workflow.stateful.interfaces.IState',
+                           'zope.app.workflow.stateful.interfaces.ITransition'],
+            'field.name':['dummy-definition'],
+            'ADD':'Add'
+            })
+        
+        self.assertEqual(response.getStatus(), 200)
+        root = self.getRootFolder()
+        mgr = zapi.traverse(root, self.basepath+'/mgr')
+        ifaces = mgr.getInterfacesForProcessName('dummy-definition')
+
+        self.assert_(nameToInterface(
+            None,
+            'zope.app.workflow.stateful.interfaces.IState'
+            ) in ifaces)
+        self.assert_(nameToInterface(
+            None,
+            'zope.app.workflow.stateful.interfaces.ITransition'
+            ) in ifaces)
+        self.assertEqual(len(ifaces),2)
+
+        response = self.publish(
+            self.basepath + '/mgr/registry.html',
+            basic='mgr:mgrpw',
+            form={
+            'mappings':
+            ['dummy-definition:zope.app.workflow.stateful.interfaces.IState',
+             'dummy-definition:zope.app.workflow.stateful.interfaces.ITransition'],
+            'REMOVE':''
+            })
+
+        ifaces = mgr.getInterfacesForProcessName('dummy-definition')
+        self.assertEqual(len(ifaces),0)
+
+
+def test_suite():
+    return unittest.makeSuite(Test)
+
+if __name__ == '__main__':
+    unittest.main()


Property changes on: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native




More information about the Zope3-Checkins mailing list