Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
275:9c74cd2635f6 | 276:b757c29b20d7 |
---|---|
534 if self.dbpool is None: | 534 if self.dbpool is None: |
535 self.__class__.dbpool = adbapi.ConnectionPool('psycopg2', | 535 self.__class__.dbpool = adbapi.ConnectionPool('psycopg2', |
536 database='pubsub_test', | 536 database='pubsub_test', |
537 cp_reconnect=True, | 537 cp_reconnect=True, |
538 client_encoding='utf-8', | 538 client_encoding='utf-8', |
539 connection_factory=NamedTupleConnection, | |
539 ) | 540 ) |
540 self.s = Storage(self.dbpool) | 541 self.s = Storage(self.dbpool) |
541 self.dbpool.start() | 542 self.dbpool.start() |
542 d = self.dbpool.runInteraction(self.init) | 543 d = self.dbpool.runInteraction(self.init) |
543 d.addCallback(lambda _: StorageTests.setUp(self)) | 544 d.addCallback(lambda _: StorageTests.setUp(self)) |
544 return d | 545 return d |
545 | 546 |
546 | 547 |
547 def tearDown(self): | 548 def tearDown(self): |
548 return self.dbpool.runInteraction(self.cleandb) | 549 d = self.dbpool.runInteraction(self.cleandb) |
550 return d.addCallback(lambda _: self.dbpool.close()) | |
549 | 551 |
550 | 552 |
551 def init(self, cursor): | 553 def init(self, cursor): |
552 self.cleandb(cursor) | 554 self.cleandb(cursor) |
553 cursor.execute("""INSERT INTO nodes | 555 cursor.execute("""INSERT INTO nodes |
623 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | 625 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
624 (OWNER.userhost(),)) | 626 (OWNER.userhost(),)) |
625 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | 627 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
626 (SUBSCRIBER.userhost(),)) | 628 (SUBSCRIBER.userhost(),)) |
627 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | 629 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
630 (SUBSCRIBER_NEW.userhost(),)) | |
631 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | |
628 (SUBSCRIBER_TO_BE_DELETED.userhost(),)) | 632 (SUBSCRIBER_TO_BE_DELETED.userhost(),)) |
629 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | 633 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
630 (SUBSCRIBER_PENDING.userhost(),)) | 634 (SUBSCRIBER_PENDING.userhost(),)) |
631 cursor.execute("""DELETE FROM entities WHERE jid=%s""", | 635 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
632 (PUBLISHER.userhost(),)) | 636 (PUBLISHER.userhost(),)) |
633 | 637 |
638 | |
634 try: | 639 try: |
635 import psycopg2 | 640 import psycopg2 |
641 psycopg2 | |
642 from psycopg2.extras import NamedTupleConnection | |
636 except ImportError: | 643 except ImportError: |
637 PgsqlStorageStorageTestCase.skip = "Psycopg2 not available" | 644 PgsqlStorageStorageTestCase.skip = "psycopg2 not available" |