def test_download(self): responses.add( responses.GET, 'http://cheddr.net/', body='success', content_type='text/plain', status=200 ) response = download('http://cheddr.net/') assert response['status_code'] == 200 assert response['text'] == 'success' assert response['headers']['Content-Type'] == 'text/plain'
def make_request(url): '''Open the URL and returns a tuple with: ( status_code headers, text ) This function is basically a celery task for the download utility ''' try: response = download(url) except (requests.ConnectionError, requests.HTTPError) as error: logger.error('Failed trying to download {}: {!r}'.format(url, error)) return -1, None, '' return [response['status_code'], dict(response['headers']), response['text']]