def test_post_success(self): """Verify that post works as expected.""" service = 'supercool' full_url = '{0}{1}'.format(self.URLBASE, service) response = dict(a='b') post_data = {'a': 'b'} # Apparently the service always returns JSON, but this seems # like a really suspicious assumption. I would really like to # verify it. httpretty.register_uri( httpretty.POST, full_url, body=json.dumps(response) ) test_base = Base(self.CERT, self.URLBASE) response_json = test_base.post(service, data=post_data) self.assertEqual(response, response_json) last_request = httpretty.last_request() self.assertEqual(last_request.parsed_body, post_data)
def test_post_failure(self): """Verify we are raising properly if a get request fails.""" test_base = Base(self.CERT, self.URLBASE) with self.assertRaises(requests.ConnectionError): test_base.post('make-beans', json.dumps(dict(beans='pinto')))