Permalink
Browse files

Tests fixed

  • Loading branch information...
1 parent deff00a commit eae3825f70c972dc98b0afb21375c1bc43cbf292 @heynemann heynemann committed Dec 12, 2012
Showing with 9 additions and 15 deletions.
  1. +5 −5 thumbor/loaders/http_loader.py
  2. +4 −10 vows/http_loader_vows.py
@@ -31,12 +31,12 @@ def validate(context, url):
return True
return False
-def return_contents(response, callback):
+def return_contents(response, url, callback):
if response.error:
- logging.error("ERROR retrieving image {0}: {1}".format(response.effective_url, str(response.error)))
+ logging.error("ERROR retrieving image {0}: {1}".format(url, str(response.error)))
callback(None)
- elif len(response.body) == 0:
- logging.error("ERROR retrieving image {0}: Empty response.".format(response.effective_url))
+ elif response.body is None or len(response.body) == 0:
+ logging.error("ERROR retrieving image {0}: Empty response.".format(url))
callback(None)
else:
callback(response.body)
@@ -47,5 +47,5 @@ def load(context, url, callback):
client = tornado.httpclient.AsyncHTTPClient()
url = _normalize_url(url)
- client.fetch(url, callback=partial(return_contents, callback=callback))
+ client.fetch(url, callback=partial(return_contents, url=url, callback=callback))
@@ -42,23 +42,17 @@ class ReturnContentVows(Vows.Context):
class ShouldReturnNoneOnError(Vows.Context):
@Vows.async_topic
def topic(self, callback):
- return loader.return_contents(ResponseMock(error='Error'), callback)
+ mock = ResponseMock(error='Error')
+ return loader.return_contents(mock, 'some-url', callback)
def should_be_none(self, topic):
expect(topic.args[0]).to_be_null()
- class ShouldReturnNoneOnInvalidContentType(Vows.Context):
- @Vows.async_topic
- def topic(self, callback):
- return loader.return_contents(ResponseMock(content_type='application/json'), callback)
-
- def should_be_none(self, topic):
- expect(topic.args[0]).to_be_null()
-
class ShouldReturnBodyIfValid(Vows.Context):
@Vows.async_topic
def topic(self, callback):
- return loader.return_contents(ResponseMock(body='body'), callback)
+ mock = ResponseMock(body='body')
+ return loader.return_contents(mock, 'some-url', callback)
def should_be_none(self, topic):
expect(topic.args[0]).to_equal('body')

0 comments on commit eae3825

Please sign in to comment.