def test_create(self): uri = 1 body = 2 headers = 3 sot = resource2._Request(uri, body, headers) self.assertEqual(uri, sot.uri) self.assertEqual(body, sot.body) self.assertEqual(headers, sot.headers)
def test_create(self): uri = 1 body = 2 headers = 3 sot = resource2._Request(uri, body, headers) self.assertEqual(uri, sot.uri) self.assertEqual(body, sot.body) self.assertEqual(headers, sot.headers)
def _prepare_request(self, requires_id=False, prepend_key=False): body = self._body.dirty if prepend_key and self.resource_key is not None: body = {self.resource_key: body} headers = self._header.dirty if requires_id: if self.id is None: raise exceptions.InvalidRequest( "Request requires an ID but none was found") uri = utils.urljoin(self.base_path, self.id) return _Request(uri, body, headers)
def _prepare_request(self, requires_id=True, prepend_key=True): """Prepare a request for the database service's create call User.create calls require the resources_key. The base_prepare_request would insert the resource_key (singular) """ body = {self.resources_key: self._body.dirty} uri = self.base_path % self._uri.attributes uri = utils.urljoin(uri, self.id) return resource._Request(uri, body, None)
def _prepare_request(self, requires_id=True, prepend_key=False): body = self._body.dirty if prepend_key and self.resource_key is not None: body = {self.resource_key: body} headers = self._header.dirty headers.update({'Content-type': 'application/json'}) # Notes: take cares for create/put, need Content-Length in headers if requires_id is False or len(body) == 0: headers.update({'Content-Length': str(len(str(body)))}) uri = self.base_path % self._uri.attributes if requires_id: if self.id is None: raise exceptions.InvalidRequest( "Request requires an ID but none was found") uri = utils.urljoin(uri, self.id) return resource._Request(uri, body, headers)
def _prepare_request(self, requires_id=True, prepend_key=False): body = self._body.dirty if prepend_key and self.resource_key is not None: body = {self.resource_key: body} headers = self._header.dirty headers.update({ 'Content-type': 'application/json', 'X-Language': 'en-us' }) uri = self.base_path % self._uri.attributes if requires_id: if self.id is None: raise exceptions.InvalidRequest( "Request requires an ID but none was found") uri = utils.urljoin(uri, self.id) return resource._Request(uri, body, headers)