def test_write_response_simple(self):
     given_url = "http://httpbin.org/get"
     response = requests.models.Response()
     response.url = given_url
     sresponse = requestions.write_response(response, return_string=False)
     self.assertIn("url", sresponse.keys())
     self.assertEqual(given_url, sresponse["url"])
 def test_responses_pedantically(self):
     given_url = "http://httpbin.org/get"
     given_headers = {"User-Agent": "Charmander/1.0"}
     given_cookies = {"__utm_soul_tracking_id": "A941ECF10959101"}
     given_status_code = 200
     given_content = "foo123"
     given_response = requests.models.Response()
     given_response.url = given_url
     given_response.headers = given_headers
     given_response.cookies = given_cookies
     given_response.status_code = given_status_code
     given_response._content = given_content
     given_sresponse = requestions.write_response(given_response)
     response = requestions.read_response(given_sresponse)
     self.assertEqual(response.url, given_response.url)
     self.assertEqual(response.headers, given_headers)
     self.assertEqual(response.status_code, given_status_code)
     self.assertEqual(dict(response.cookies), given_cookies)
     self.assertEqual(response.content, given_content)