comparison idavoll/test/test_storage.py @ 204:b4bf0a5ce50d

Implement storage facilities for the HTTP gateway. Author: ralphm. Fixes #12. One of the storage facilities is PostgreSQL based, providing persistence.
author Ralph Meijer <ralphm@ik.nu>
date Wed, 16 Jul 2008 06:38:32 +0000
parents 77c61e2b8c75
children 274a45d2a5ab
comparison
equal deleted inserted replaced
203:2c46e6664680 204:b4bf0a5ce50d
412 return StorageTests.setUp(self) 412 return StorageTests.setUp(self)
413 413
414 414
415 415
416 class PgsqlStorageStorageTestCase(unittest.TestCase, StorageTests): 416 class PgsqlStorageStorageTestCase(unittest.TestCase, StorageTests):
417 def _callSuperSetUp(self, void):
418 return StorageTests.setUp(self)
419
420 417
421 def setUp(self): 418 def setUp(self):
422 from idavoll.pgsql_storage import Storage 419 from idavoll.pgsql_storage import Storage
423 self.s = Storage('ralphm', 'pubsub_test') 420 from twisted.enterprise import adbapi
424 self.s._dbpool.start() 421 self.dbpool = adbapi.ConnectionPool('pyPgSQL.PgSQL',
425 d = self.s._dbpool.runInteraction(self.init) 422 database='pubsub_test',
426 d.addCallback(self._callSuperSetUp) 423 cp_reconnect=True,
427 return d 424 client_encoding='utf-8',
428 425 )
429 426 self.s = Storage(self.dbpool)
430 def tearDownClass(self): 427 self.dbpool.start()
431 #return self.s._dbpool.runInteraction(self.cleandb) 428 d = self.dbpool.runInteraction(self.init)
432 pass 429 d.addCallback(lambda _: StorageTests.setUp(self))
430 return d
431
432
433 def tearDown(self):
434 return self.dbpool.runInteraction(self.cleandb)
433 435
434 436
435 def init(self, cursor): 437 def init(self, cursor):
436 self.cleandb(cursor) 438 self.cleandb(cursor)
437 cursor.execute("""INSERT INTO nodes (node) VALUES ('pre-existing')""") 439 cursor.execute("""INSERT INTO nodes (node) VALUES ('pre-existing')""")