diff sat_pubsub/test/test_storage.py @ 276:b757c29b20d7

import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
author souliane <souliane@mailoo.org>
date Mon, 13 Oct 2014 15:59:25 +0200
parents 560b6cdc50b2
children 002c59dbc23f
line wrap: on
line diff
--- a/sat_pubsub/test/test_storage.py	Thu Aug 01 16:22:14 2013 -0700
+++ b/sat_pubsub/test/test_storage.py	Mon Oct 13 15:59:25 2014 +0200
@@ -536,6 +536,7 @@
                                             database='pubsub_test',
                                             cp_reconnect=True,
                                             client_encoding='utf-8',
+                                            connection_factory=NamedTupleConnection,
                                             )
         self.s = Storage(self.dbpool)
         self.dbpool.start()
@@ -545,7 +546,8 @@
 
 
     def tearDown(self):
-        return self.dbpool.runInteraction(self.cleandb)
+        d = self.dbpool.runInteraction(self.cleandb)
+        return d.addCallback(lambda _: self.dbpool.close())
 
 
     def init(self, cursor):
@@ -625,13 +627,18 @@
         cursor.execute("""DELETE FROM entities WHERE jid=%s""",
                        (SUBSCRIBER.userhost(),))
         cursor.execute("""DELETE FROM entities WHERE jid=%s""",
+                       (SUBSCRIBER_NEW.userhost(),))
+        cursor.execute("""DELETE FROM entities WHERE jid=%s""",
                        (SUBSCRIBER_TO_BE_DELETED.userhost(),))
         cursor.execute("""DELETE FROM entities WHERE jid=%s""",
                        (SUBSCRIBER_PENDING.userhost(),))
         cursor.execute("""DELETE FROM entities WHERE jid=%s""",
                        (PUBLISHER.userhost(),))
 
+
 try:
     import psycopg2
+    psycopg2
+    from psycopg2.extras import NamedTupleConnection
 except ImportError:
-    PgsqlStorageStorageTestCase.skip = "Psycopg2 not available"
+    PgsqlStorageStorageTestCase.skip = "psycopg2 not available"