diff idavoll/test/test_storage.py @ 139:8f6956b9a688

Follow API change in Twisted Xish, while still being compatible with Twisted Xish 0.1.0.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 27 Apr 2005 19:45:41 +0000
parents 635e433810ef
children 812300cdbc22
line wrap: on
line diff
--- a/idavoll/test/test_storage.py	Mon Apr 25 13:02:37 2005 +0000
+++ b/idavoll/test/test_storage.py	Wed Apr 27 19:45:41 2005 +0000
@@ -31,6 +31,11 @@
 ITEM_TO_NOT_BE_DELETED.addElement(('testns', 'test'),
                                   content=u'Test \u2083 item')
 
+def decode(object):
+    if isinstance(object, str):
+        object = object.decode('utf-8')
+    return object
+
 class StorageTests:
 
     def _assignTestNode(self, node):
@@ -225,7 +230,7 @@
             return self.node.get_items_by_id(['new'])
 
         def cb2(result):
-            assertEqual(result[0], unicode(ITEM_NEW.toXml(), 'utf-8'))
+            assertEqual(result[0], decode(ITEM_NEW.toXml()))
 
         d = self.node.store_items([ITEM_NEW], PUBLISHER)
         d.addCallback(cb1)
@@ -237,7 +242,7 @@
             return self.node.get_items_by_id(['current'])
 
         def cb2(result):
-            assertEqual(result[0], unicode(ITEM_UPDATED.toXml(), 'utf-8'))
+            assertEqual(result[0], decode(ITEM_UPDATED.toXml()))
 
         d = self.node.store_items([ITEM_UPDATED], PUBLISHER)
         d.addCallback(cb1)
@@ -263,7 +268,7 @@
 
     def testGetItems(self):
         def cb(result):
-            assertIn(unicode(ITEM.toXml(), 'utf-8'), result)
+            assertIn(decode(ITEM.toXml()), result)
 
         d = self.node.get_items()
         d.addCallback(cb)
@@ -271,7 +276,7 @@
 
     def testLastItem(self):
         def cb(result):
-            assertEqual([unicode(ITEM.toXml(), 'utf-8')], result)
+            assertEqual([decode(ITEM.toXml())], result)
 
         d = self.node.get_items(1)
         d.addCallback(cb)
@@ -333,14 +338,14 @@
         subscriptions[SUBSCRIBER_PENDING.full()] = \
                 Subscription('pending')
 
-        item = (ITEM_TO_BE_DELETED.toXml(), PUBLISHER)
+        item = (decode(ITEM_TO_BE_DELETED.toXml()), PUBLISHER)
         self.s._nodes['pre-existing']._items['to-be-deleted'] = item
         self.s._nodes['pre-existing']._itemlist.append(item)
         self.s._nodes['pre-existing']._items['to-not-be-deleted'] = item
         self.s._nodes['pre-existing']._itemlist.append(item)
         self.s._nodes['to-be-purged']._items['to-be-deleted'] = item
         self.s._nodes['to-be-purged']._itemlist.append(item)
-        item = (ITEM.toXml(), PUBLISHER)
+        item = (decode(ITEM.toXml()), PUBLISHER)
         self.s._nodes['pre-existing']._items['current'] = item
         self.s._nodes['pre-existing']._itemlist.append(item)