def test_http_post_type(self): """Test the HTTP POST request return value type""" http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE") http_text = http.post() if state.py2: self.assertEqual(type(u"test string"), type(http_text)) else: self.assertEqual(type(str("test string")), type(http_text))
def test_http_post_type(self): """Test the HTTP POST request return value type""" http = HTTP( "https://raw.github.com/chrissimpkins/six-four/master/LICENSE") http_text = http.post() if state.py2: self.assertEqual(type(u"test string"), type(http_text)) else: self.assertEqual(type(str("test string")), type(http_text))
def test_http_post_response_status_200_ssl(self): """Test that the status code 200 is appropriately detected after a SSL POST request""" http = HTTP("https://httpbin.org/post") http.post() self.assertEqual(http.res.status_code, 200)
def test_http_get_response_method_return_value_missingsite(self): """Test the return type from response() method when non-existent site is requested""" http = HTTP('http://www.abogussitename.com') http.post() self.assertEqual(None, http.response())
def test_http_get_response_content_object_missingsite(self): """Test the contents of the response object returned by requests when site is non-existent""" http = HTTP('http://www.abogussitename.com') http.post() with self.assertRaises(AttributeError): http.res.content # confirm that attempt to access the content attribute of res raises Exception when no site
def test_http_POST_response_object_missingsite(self): """Test the POST response object returned by requests when site is non-existent""" http = HTTP('http://www.abogussitename.com') http.post() self.assertEqual(None, http.res)
def test_http_post_contents_response_missingsite(self): """Test the contents of the POST request response when the site is non-existent""" http = HTTP('http://www.abogussitename.com') self.assertEqual(False, http.post()) # returns False if requests ConnectionError
def test_http_post_ssl(self): """Test HTTP POST request content data""" http = HTTP("https://httpbin.org/post") http_text = http.post() response = http.response() self.assertEqual(response.url, 'https://httpbin.org/post')
def test_http_post_contents_response_missingsite(self): """Test the contents of the POST request response when the site is non-existent""" http = HTTP('http://www.abogussitename.com') self.assertEqual( False, http.post()) # returns False if requests ConnectionError