Esempio n. 1
0
 def test_text_404_ignore(self):
     httpretty.register_uri(httpretty.GET, 'http://www.ckan.org/',
                            body=u'{"success": true}',
                            content_type='html/text',
                            status=404)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me', good_status=(200, 201, 404))
Esempio n. 2
0
 def test_text_409_with_broken_json(self):
     httpretty.register_uri(httpretty.GET, 'http://www.ckan.org/',
                            body=u"This is someone's text. With ümlauts.",
                            content_type='html/text',
                            status=409)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me')
Esempio n. 3
0
 def test_text_500_with_false_success(self):
     httpretty.register_uri(httpretty.GET, 'http://www.ckan.org/',
                            body=u'{"success": false}',
                            content_type='html/text',
                            status=500)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me')
Esempio n. 4
0
 def test_text_404_ignore(self):
     httpretty.register_uri(httpretty.GET, 'http://www.ckan.org/',
                            body=u'{"success": true}',
                            content_type='html/text',
                            status=404)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me', good_status=(200, 201, 404))
Esempio n. 5
0
 def test_text_200(self):
     httpretty.register_uri(httpretty.GET, 'http://www.ckan.org/',
                            body=u'{"success": true}',
                            content_type='html/text',
                            status=200)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me')
Esempio n. 6
0
 def test_text_409_with_broken_json(self):
     httpretty.register_uri(httpretty.GET,
                            'http://www.ckan.org/',
                            body=u"This is someone's text. With ümlauts.",
                            content_type='html/text',
                            status=409)
     r = requests.get('http://www.ckan.org/')
     jobs.check_response(r, 'http://www.ckan.org/', 'Me')
Esempio n. 7
0
 def test_text_409_with_non_json_response(self):
     """It should raise HTTPError for a 409 with a non-JSON body."""
     url = 'http://www.ckan.org/'
     httpretty.register_uri(httpretty.GET, url,
                            body=u"This is someone's text. With ümlauts.",
                            content_type='html/text',
                            status=409)
     r = requests.get('http://www.ckan.org/')
     try:
         jobs.check_response(r, 'http://www.ckan.org/', 'Me')
         assert False, "check_response() should have raised an exception."
     except jobs.HTTPError as err:
         assert err.status_code == 409
         assert err.request_url == url
Esempio n. 8
0
 def test_text_500_with_false_success(self):
     """It should raise HTTPError if given a 500 with "success": false."""
     url = 'http://www.ckan.org/'
     httpretty.register_uri(httpretty.GET, url,
                            body=u'{"success": false}',
                            content_type='html/text',
                            status=500)
     r = requests.get('http://www.ckan.org/')
     try:
         jobs.check_response(r, url, 'Me')
         assert False, "check_response() should have raised an exception"
     except jobs.HTTPError as err:
         assert err.response == '{"success": false}'
         assert err.status_code == 500
         assert err.request_url == url