def _run_and_configure_db(self): yield self.db_process.restart() c = self.db_process.get_config() db_host, db_port, db_name = c['host'], c['port'], 'test' db = database.Database(db_host, db_port, db_name) self.db = db.get_connection() yield dbtools.create_db(self.db) yield dbtools.push_initial_data(self.db) defer.returnValue((db_host, db_port, db_name, ))
def testDefiningDocument(self): dbtools.initial_data(SomeDocument) dbtools.initial_data( SomeDocument(doc_id=u'special_id', field1=u'special')) yield dbtools.push_initial_data(self.connection) # 3 = 2 (registered documents) + 1 (design document) self.assertEqual(3, len(self.db._documents)) special = yield self.connection.get_document('special_id') self.assertIsInstance(special, SomeDocument) self.assertEqual('special', special.field1) ids = self.db._documents.keys() other_id = filter(lambda x: x not in ('special_id', "_design/feat"), ids)[0] normal = yield self.connection.get_document(other_id) self.assertEqual('default', normal.field1)
def initiate(self): self._database_connection = self._database.get_connection() d1 = dbtools.push_initial_data(self._database_connection) d2 = self._jourwriter.initiate() self._journaler.configure_with(self._jourwriter) return defer.DeferredList([d1, d2])