diff idavoll/test/test_backend.py @ 167:ef22e4150caa

Move protocol implementations (pubsub, disco, forms) to and depend on wokkel. Author: ralphm Fixes: #4
author Ralph Meijer <ralphm@ik.nu>
date Wed, 03 Oct 2007 12:41:43 +0000
parents 21fcfb86433f
children e2c2c2baf483
line wrap: on
line diff
--- a/idavoll/test/test_backend.py	Thu Jan 18 14:08:32 2007 +0000
+++ b/idavoll/test/test_backend.py	Wed Oct 03 12:41:43 2007 +0000
@@ -1,12 +1,16 @@
-# Copyright (c) 2003-2006 Ralph Meijer
+# Copyright (c) 2003-2007 Ralph Meijer
 # See LICENSE for details.
 
+"""
+Tests for L{idavoll.backend}.
+"""
+
 from twisted.trial import unittest
 from zope.interface import implements
 from twisted.internet import defer
 from twisted.words.protocols.jabber import jid
 
-from idavoll import backend, storage
+from idavoll import backend, error, iidavoll
 
 OWNER = jid.JID('owner@example.com')
 
@@ -18,25 +22,26 @@
 
 class testStorage:
 
-    implements(storage.IStorage)
+    implements(iidavoll.IStorage)
 
     def get_node(self, node_id):
         return defer.succeed(testNode())
 
     def delete_node(self, node_id):
         if node_id in ['to-be-deleted']:
-            self.backend.delete_called = True
+            self.delete_called = True
             return defer.succeed(None)
         else:
-            return defer.fail(storage.NodeNotFound())
+            return defer.fail(error.NodeNotFound())
 
-class NodeDeletionServiceTests:
-    pre_delete_called = False
-    delete_called = False
+class BackendTest(unittest.TestCase):
+    def setUp(self):
+        self.storage = testStorage()
+        self.backend = backend.BackendService(self.storage)
+        self.storage.backend = self.backend
 
-    def setUpClass(self):
-        self.storage = testStorage()
-        self.storage.backend = self
+        self.pre_delete_called = False
+        self.delete_called = False
 
     def testDeleteNode(self):
         def pre_delete(node_id):
@@ -44,19 +49,10 @@
             return defer.succeed(None)
 
         def cb(result):
-            self.assert_(self.pre_delete_called)
-            self.assert_(self.delete_called)
+            self.assertTrue(self.pre_delete_called)
+            self.assertTrue(self.storage.delete_called)
 
         self.backend.register_pre_delete(pre_delete)
         d = self.backend.delete_node('to-be-deleted', OWNER)
         d.addCallback(cb)
-
-class GenericNodeDeletionServiceTestCase(unittest.TestCase,
-                                         NodeDeletionServiceTests):
-
-    def setUpClass(self):
-        NodeDeletionServiceTests.setUpClass(self)
-        from idavoll.generic_backend import BackendService, NodeDeletionService
-        bs = BackendService(self.storage)
-        self.backend = NodeDeletionService()
-        self.backend.setServiceParent(bs)
+        return d