[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/workflow/ Entering a workflow xml ttw caused an error,

Eckart Hertzler eckart at hertzler.de
Thu Sep 16 10:09:31 EDT 2004


Log message for revision 27548:
  
    Entering a workflow xml ttw caused an error,
    because the xml parser only accepty normal
    strings, but got a unicode string.
  
    - added a ftest
    - convert xml to string before importing
  
  


Changed:
  U   Zope3/trunk/src/zope/app/workflow/browser/definition.py
  U   Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py


-=-
Modified: Zope3/trunk/src/zope/app/workflow/browser/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/browser/definition.py	2004-09-16 14:05:40 UTC (rev 27547)
+++ Zope3/trunk/src/zope/app/workflow/browser/definition.py	2004-09-16 14:09:29 UTC (rev 27548)
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 """ProcessDefinition registration adding view
- 
+
 $Id$
 """
 
@@ -23,7 +23,7 @@
 
 
 class ProcessDefinitionView(object):
- 
+
     def getName(self):
         return """I'm a dummy ProcessInstance"""
 
@@ -31,7 +31,7 @@
 class ImportExportView(object):
 
     def importDefinition(self):
-        xml = self.request.get('definition')
+        xml = str(self.request.get('definition'))
         if xml:
             IProcessDefinitionImportHandler(self.context).doImport(xml)
         self.request.response.redirect('@@importexport.html?success=1')

Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py	2004-09-16 14:05:40 UTC (rev 27547)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py	2004-09-16 14:09:29 UTC (rev 27548)
@@ -22,6 +22,34 @@
 from zope.app.tests.functional import BrowserTestCase
 from zope.app.workflow.stateful.definition import StatefulProcessDefinition
 
+xml=u"""<?xml version="1.0"?>
+<workflow type="StatefulWorkflow"
+          title="Foo Test Workflow">
+
+  <schema name="">
+    <permissions>
+    </permissions>
+  </schema>
+
+  <states>
+    <state title="initial" name="INITIAL"/>
+    <state title="Foo" name="foo"/>
+  </states>
+
+  <transitions>
+
+      <transition sourceState="INITIAL"
+                  destinationState="foo"
+                  permission="zope.Public"
+                  triggerMode="Automatic"
+                  title="Make Foo"
+                  name="initial_foo"/>
+
+  </transitions>
+
+</workflow>"""
+
+
 class Test(BrowserTestCase):
 
     def setUp(self):
@@ -61,7 +89,24 @@
         body = ' '.join(response.getBody().split())
         self.assert_(body.find('This object is not currently active.') >=0)
 
+    def test_transitions(self):
         response = self.publish(
+            self.basepath + '/pd/transitions/contents.html',
+            basic='mgr:mgrpw')
+
+        self.assertEqual(response.getStatus(), 200)
+
+    def test_states(self):
+        response = self.publish(
+            self.basepath + '/pd/states/contents.html',
+            basic='mgr:mgrpw')
+
+        self.assertEqual(response.getStatus(), 200)
+        body = ' '.join(response.getBody().split())
+        self.assert_(body.find('INITIAL') >= 0)
+
+    def test_xmlimport(self):
+        response = self.publish(
             self.basepath + '/pd/importexport.html',
             basic='mgr:mgrpw')
 
@@ -73,23 +118,28 @@
         self.assert_(body.find(
             '<a href="transitions/contents.html">Manage Transitions</a>') >=0)
 
-    def test_transitions(self):
         response = self.publish(
-            self.basepath + '/pd/transitions/contents.html',
-            basic='mgr:mgrpw')
+            self.basepath + '/pd/import.html',
+            basic='mgr:mgrpw',
+            form={'definition': xml})
 
-        self.assertEqual(response.getStatus(), 200)
+        self.assertEqual(response.getStatus(), 302)
+        self.assertEqual(response.getHeader('Location'),
+                         '@@importexport.html?success=1')
 
-    def test_states(self):
         response = self.publish(
-            self.basepath + '/pd/states/contents.html',
-            basic='mgr:mgrpw')
+            self.basepath + '/pd/'+response.getHeader('Location'),
+            basic='mgr:mgrpw',
+            form={'definition': xml})
 
         self.assertEqual(response.getStatus(), 200)
         body = ' '.join(response.getBody().split())
-        self.assert_(body.find('INITIAL') >= 0)
 
+        self.assert_(body.find('initial_foo') >= 0)
 
+        self.assert_(body.find('Import was successfull!') >= 0)
+
+
 def test_suite():
     return unittest.makeSuite(Test)
 



More information about the Zope3-Checkins mailing list