def test_add_task(self): client = BoxClient("my_token") due_at = datetime.now() expected_data = {"item": {"type": "file", "id": 123}, "action": "review", "due_at": str(due_at), "message": "test" } response = {"type": "task", "id": 123, "action": "review", "message": "test", "due_at": str(due_at) } (flexmock(requests) .should_receive('request') .with_args("post", "https://api.box.com/2.0/tasks", params=None, data=json.dumps(expected_data), headers=client.default_headers) .and_return(mocked_response(response))) task = client.add_task(123, due_at, message="test") self.assertEquals(task, response)