[Zope3-checkins] CVS: Packages3/workflow/stateful/tests - test_xmlimportexport.py:1.2
Ulrich Eck
ueck@net-labs.de
Wed, 9 Apr 2003 14:36:01 -0400
Update of /cvs-repository/Packages3/workflow/stateful/tests
In directory cvs.zope.org:/tmp/cvs-serv18601/stateful/tests
Modified Files:
test_xmlimportexport.py
Log Message:
added a parameter definition_name to createProcessInstance
that eases the implementation alot and avoids some Wrapper-hacks
updated all tests accordingly
added canImport implementation to stateful/xmlimportexport and tests
cleanup a bit
=== Packages3/workflow/stateful/tests/test_xmlimportexport.py 1.1 => 1.2 ===
--- Packages3/workflow/stateful/tests/test_xmlimportexport.py:1.1 Mon Apr 7 13:33:51 2003
+++ Packages3/workflow/stateful/tests/test_xmlimportexport.py Wed Apr 9 14:35:31 2003
@@ -12,7 +12,10 @@
#
##############################################################################
import unittest
+from StringIO import StringIO
+
from zope.interface.verify import verifyClass
+from zope.interface.implements import implements
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.component.adapter import provideAdapter
@@ -40,7 +43,7 @@
xml_text = """<?xml version="1.0"?>
-<workflow type="Zope3Workflow" title="TestPD">
+<workflow type="StatefulWorkflow" title="TestPD">
<schema name="Some.path.to.an.ISchemaClass">
</schema>
@@ -83,21 +86,15 @@
</workflow>
"""
-# XXX Ugly Hack to simulate <implements directive
-
-State.__implements__ = State.__implements__, \
- IAttributeAnnotatable
-
-Transition.__implements__ = Transition.__implements__, \
- IAttributeAnnotatable
-
-
-
class TestProcessDefinition(StatefulProcessDefinition):
__implements__ = IAttributeAnnotatable, IUseConfigurable, \
StatefulProcessDefinition.__implements__
+# need to patch this cause these classes are used directly
+# in the import/export classes
+implements(State, IAttributeAnnotatable)
+implements(Transition, IAttributeAnnotatable)
@@ -115,7 +112,12 @@
def testImport(self):
testpd = TestProcessDefinition()
handler = XMLImportHandler()
- handler.doImport(testpd, xml_text)
+
+ self.assertEqual(handler.canImport(testpd, StringIO(xml_text)), True)
+ self.assertEqual(handler.canImport(None, StringIO(xml_text)), False)
+ self.assertEqual(handler.canImport(None, StringIO('<some><nonworking/><xml/></some>')), False)
+
+ handler.doImport(testpd, StringIO(xml_text))
self.assertEqual(testpd.getRelevantDataSchema(), 'Some.path.to.an.ISchemaClass')
self.assertEqual(getAdapter(testpd, IZopeDublinCore).title, 'TestPD')