Skip to content

Commit

Permalink
Returns the tuple (resource, response)
Browse files Browse the repository at this point in the history
  • Loading branch information
scastillo committed May 17, 2011
1 parent 817fa0a commit b125dd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions siesta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def _getresponse(self, method, url, body={}, headers={}, meta={}):
raise Exception('Empty content-location from server')

status_uri = urlparse(status_url).path
status = Resource(uri=status_uri, api=self.api).get()
status, st_resp = Resource(uri=status_uri, api=self.api).get()
retries = 0
MAX_RETRIES = 3
resp_status = status.conn.getresponse().status
resp_status = st_resp.status
logging.info("##########33>>>>>>>> status: %s" % resp_status)
while resp_status != 303 and retries < MAX_RETRIES:
logging.info('retry #%s' % retries)
Expand Down Expand Up @@ -241,7 +241,7 @@ def _getresponse(self, method, url, body={}, headers={}, meta={}):
if ret:
self.attrs.update(ret)
# return self here and none otherwise?
return self
return self, resp


class API(object):
Expand Down
13 changes: 7 additions & 6 deletions siesta/tests/test_siesta.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@ def test_post(self):
self.response.read.return_value = expected_response
self.response.status = 200

obj = self.api.obj.post(attr='value')
obj, resp = self.api.obj.post(attr='value')
logging.info(obj.headers)
logging.info("response: %s" % resp)
#raise Exception()
self.assertEqual(expected_response, json.dumps(obj.attrs))

def test_put(self):
expected_response = json.dumps(dict(user='123', id='QWERTY123'))
self.response.read.return_value = expected_response
self.response.status = 200

obj = self.api.obj(1).put(attr='value')
# lunes 730
obj = self.api.obj.put(attr='value')
logging.info(obj)

def test_delete(self):
expected_response = json.dumps(dict(user='123', id='QWERTY123'))
self.response.read.return_value = expected_response
self.response.status = 200

obj = self.api.obj().delete(1)
obj, resp = self.api.obj().delete(1)
logging.info(obj)

def test_202_accepted(self):
Expand Down Expand Up @@ -99,15 +100,15 @@ def getheader(header):
)
response.read.return_value = expected_response

obj = self.api.collection.post(attr='value')
obj, resp = self.api.collection.post(attr='value')
logging.info(obj)

def test_siesta(self):
expected_response = json.dumps(dict(user='123', id='QWERTY123'))
self.response.read.return_value = expected_response
self.response.status = 200

sess = self.api.sessions().post(user='123')
sess, resp = self.api.sessions().post(user='123')
#user1 = self.api.users(id=1)
apps = self.api.users(id=1).applications(123)
apps.get()
Expand Down

0 comments on commit b125dd9

Please sign in to comment.