diff idavoll/test/test_backend.py @ 220:e59b48f3f636

Add tests for subscription and unsubscription JID checks in [53d2c0019458].
author Ralph Meijer <ralphm@ik.nu>
date Sat, 16 Oct 2010 20:54:52 +0200
parents bfc198af5d27
children 698af5d720ad
line wrap: on
line diff
--- a/idavoll/test/test_backend.py	Sat Oct 16 20:02:47 2010 +0200
+++ b/idavoll/test/test_backend.py	Sat Oct 16 20:54:52 2010 +0200
@@ -18,6 +18,7 @@
 from idavoll import backend, error, iidavoll
 
 OWNER = jid.JID('owner@example.com')
+OWNER_FULL = jid.JID('owner@example.com/home')
 SERVICE = jid.JID('test.example.org')
 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
 
@@ -32,7 +33,7 @@
         class TestNode:
             nodeIdentifier = 'to-be-deleted'
             def getAffiliation(self, entity):
-                if entity is OWNER:
+                if entity.userhostJID() == OWNER:
                     return defer.succeed('owner')
 
         class TestStorage:
@@ -66,7 +67,7 @@
         preDeleteCalled = []
 
         self.backend.registerPreDelete(preDelete)
-        d = self.backend.deleteNode('to-be-deleted', OWNER)
+        d = self.backend.deleteNode('to-be-deleted', OWNER_FULL)
         d.addCallback(cb)
         return d
 
@@ -77,7 +78,7 @@
         class TestNode:
             nodeIdentifier = 'to-be-deleted'
             def getAffiliation(self, entity):
-                if entity is OWNER:
+                if entity.userhostJID() == OWNER:
                     return defer.succeed('owner')
 
         class TestStorage:
@@ -137,7 +138,7 @@
             self.assertNotIdentical(None, nodeIdentifier)
             self.assertIdentical(self.storage.nodeIdentifier, nodeIdentifier)
 
-        d = self.backend.createNode(None, OWNER)
+        d = self.backend.createNode(None, OWNER_FULL)
         d.addCallback(checkID)
         return d
 
@@ -300,7 +301,7 @@
         class testNode:
             nodeIdentifier = 'node'
             def getAffiliation(self, entity):
-                if entity is OWNER:
+                if entity.userhostJID() == OWNER:
                     return defer.succeed('owner')
             def setConfiguration(self, options):
                 self.options = options
@@ -330,7 +331,7 @@
         options = {'pubsub#deliver_payloads': True,
                    'pubsub#persist_items': False}
 
-        d = self.backend.setNodeConfiguration('node', options, OWNER)
+        d = self.backend.setNodeConfiguration('node', options, OWNER_FULL)
         d.addCallback(cb)
         return d
 
@@ -343,7 +344,7 @@
             nodeType = 'leaf'
             nodeIdentifier = 'node'
             def getAffiliation(self, entity):
-                if entity is OWNER:
+                if entity.userhostJID() == OWNER:
                     return defer.succeed('owner')
             def getConfiguration(self):
                 return {'pubsub#deliver_payloads': True,
@@ -363,7 +364,7 @@
         self.backend.registerNotifier(checkID)
 
         items = [pubsub.Item()]
-        d = self.backend.publish('node', items, OWNER)
+        d = self.backend.publish('node', items, OWNER_FULL)
         return d
 
 
@@ -409,7 +410,7 @@
         d1 = defer.Deferred()
         d1.addCallback(cb)
         self.backend.registerNotifier(d1.callback)
-        d2 = self.backend.subscribe('node', OWNER, OWNER)
+        d2 = self.backend.subscribe('node', OWNER, OWNER_FULL)
         return defer.gatherResults([d1, d2])
 
     test_notifyOnSubscription.timeout = 2