def test_post_comment(self): httpretty.register_uri( httpretty.GET, _MESSAGE_URL, status=200, body=_MESSAGE_BODY) httpretty.register_uri( httpretty.POST, _MESSAGE_URL + '/comments', status=200, body='OK') m = Message(_MESSAGE_URL, {'_managebac_session': 'TOKEN'}) m.post_comment('Hello World!', {'_managebac_session': 'TOKEN'}) body = httpretty.last_request().parsed_body self.assertEqual(body['post[body]'], ['Hello World!']) self.assertIn('_managebac_session=TOKEN', httpretty.last_request().headers['Cookie'], 'Sent the token as a cookie')