[Zope-CVS] CVS: Packages3/workflow/tests - test_instance.py:1.3

Ulrich Eck ueck@net-labs.de
Fri, 7 Feb 2003 16:50:54 -0500


Update of /cvs-repository/Packages3/workflow/tests
In directory cvs.zope.org:/tmp/cvs-serv15434/tests

Modified Files:
	test_instance.py 
Log Message:
First usable state of Stateful Workflow :)
- Implemented ProcessInstanceContainer/Adapter + Views
- Implemented Dummy ContentWorkflowsUtility
- updated Readme
- fixed some bugs
 --> read the README for a small tutorial of what works


=== Packages3/workflow/tests/test_instance.py 1.2 => 1.3 ===
--- Packages3/workflow/tests/test_instance.py:1.2	Wed Feb  5 20:09:34 2003
+++ Packages3/workflow/tests/test_instance.py	Fri Feb  7 16:50:53 2003
@@ -13,14 +13,23 @@
 ##############################################################################
 
 import unittest
-
 from zope.interface.verify import verifyClass
 
+from zope.app.interfaces.annotation import IAnnotations
+from zope.app.tests.placelesssetup import PlacelessSetup
+
 from zope.app.interfaces.workflow import IProcessInstance
 from zope.app.workflow.instance import ProcessInstance
 
 from zope.app.interfaces.workflow import IProcessInstanceContainer
-from zope.app.workflow.instance import ProcessInstanceContainerAdapter
+from zope.app.workflow.instance import ProcessInstanceContainerAdapter, WFKey
+
+class TestAnnotations(dict):
+
+    __implements__ = IAnnotations
+
+class DummyInstance:
+    pass
 
 
 class ProcessInstanceTests(unittest.TestCase):
@@ -30,11 +39,44 @@
 
 
 
-class ProcessInstanceContainerAdapterTests(unittest.TestCase):
+class ProcessInstanceContainerAdapterTests(PlacelessSetup, unittest.TestCase):
 
     def testInterface(self):
         verifyClass(IProcessInstanceContainer,
                     ProcessInstanceContainerAdapter)
+
+    def testAdapter(self):
+
+        annotations = TestAnnotations()
+        di = DummyInstance()
+        pica = ProcessInstanceContainerAdapter(annotations)
+
+        self.assertEqual(annotations.keys(), [WFKey,])
+        self.assertEqual(len(pica), 0)
+        self.assertEqual(pica.keys(), [])
+        self.assertEqual(pica.items(), [])
+        self.assertEqual(pica.values(), [])
+        self.assertEqual(pica.get('nothing', 1), 1)
+        self.assertRaises(TypeError, pica.setObject, 123, None)
+        
+        pica.setObject('dummy', di)
+        self.assertEqual(len(pica), 1)
+        self.assertEqual(pica.keys(), ['dummy'])
+        self.assertEqual(pica.values(), [di])
+        self.assertEqual(pica.items(), [('dummy', di,),])
+        self.assertEqual(pica['dummy'], di)
+        self.assertEqual(pica.get('dummy', 1), di)
+        self.failUnless('dummy' in pica)
+
+        del pica['dummy']
+
+        self.assertEqual(len(pica), 0)
+        self.failIf('dummy' in pica)
+        
+        
+
+
+
 
 
 def test_suite():