def run(): s = paisley.CouchDB('localhost') d = s.createDB('benchmarks') d.addBoth(_printCb) d.addCallback(lambda _: run_tests(s)) return d
def __init__(self): self.db = paisley.CouchDB('localhost') self.buckets = {HEADER: "mailheader", BODY: "mailbody", META: "mailmeta} self.rev_cache = {} # couch needs to keep track of revs d = self.db.listDB() def cb1(r): print(r.getResult()) d.addCallback(cb1)
def setUp(self): """ Create a web server and a client bound to it. """ self.resource = FakeCouchDBResource() site = server.Site(self.resource) port = reactor.listenTCP(0, site, interface="127.0.0.1") self.addCleanup(port.stopListening) self.client = paisley.CouchDB("127.0.0.1", port.getHost().port)
def test_auth_init(self): """ Test setting up client with authentication """ self.client_auth = paisley.CouchDB("localhost", username="******", password="******") self.assertEquals(self.client_auth.username, "test") self.assertEquals(self.client_auth.password, "testpass")
def test(): foo = paisley.CouchDB('localhost') print "\nCreate database 'mydb':" d = foo.createDB('mydb') wfd = defer.waitForDeferred(d) yield wfd try: print wfd.getResult() except error.Error, e: # FIXME: not sure why Error.status is a str compared to http constants if e.status == str(http.UNAUTHORIZED): print "\nError: not allowed to create databases" reactor.stop() return else: raise
def get_couch(): try: port = config.CONF.getint('db', 'port') except: port = 5984 return paisley.CouchDB(config.CONF.get('db', 'host'), port=port)