def testPush(self): reg_info ={ "location": "https://globaldbs", "admin": "*****@*****.**", "type": "DBS", "name": "Global DBS", "timeout": 2 } reg = Registration({'server': self.testInit.couchUrl, 'database': self.couch_db}, reg_info) json = BasicAuthJSONRequests(self.testInit.couchUrl) data = json.get('/%s/%s' % (self.couch_db, str(reg_info['location'].__hash__()))) for k, v in reg_info.items(): if k != 'timestamp': assert data[0][k] == v, \ "Registration incomplete: %s should equal %s for key %s" % (data[0][k], v, k)
def testPush(self): reg_info = { "location": "https://globaldbs", "admin": "*****@*****.**", "type": "DBS", "name": "Global DBS", "timeout": 2 } reg = Registration( { 'server': self.testInit.couchUrl, 'database': self.couch_db }, reg_info) json = BasicAuthJSONRequests(self.testInit.couchUrl) data = json.get('/%s/%s' % (self.couch_db, str(reg_info['location'].__hash__()))) for k, v in reg_info.items(): if k != 'timestamp': assert data[0][k] == v, \ "Registration incomplete: %s should equal %s for key %s" % (data[0][k], v, k)
def makeRequest(self, uri=None, data=None, type='GET', incoming_headers={}, encode=True, decode=True, contentType=None, cache=False): """ Make the request, handle any failed status, return just the data (for compatibility). By default do not cache the response. TODO: set caching in the calling methods. """ try: if not cache: incoming_headers.update({'Cache-Control': 'no-cache'}) result, status, reason, cached = BasicAuthJSONRequests.makeRequest( self, uri, data, type, incoming_headers, encode, decode, contentType) except HTTPException, e: self.checkForCouchError(getattr(e, "status", None), getattr(e, "reason", None), data)
def __init__(self, url='http://localhost:5984'): """ Initialise requests """ BasicAuthJSONRequests.__init__(self, url) self.accept_type = "application/json"