def test_include__accounting(self): includes = IncludesBuilder() includes.include("late_reminders") assert includes.build( "AccountingResource") == "&include[]=late_reminders" assert str(includes) == "IncludesBuilder(&include[]=late_reminders)"
def test_list_clients__includes(self): url = ( "{}/accounting/account/{}/users/clients?include[]=late_reminders&include[]=last_activity" ).format(API_BASE_URL, self.account_id) httpretty.register_uri(httpretty.GET, url, body=json.dumps( get_fixture("list_clients_response")), status=200) includes = IncludesBuilder() includes.include("late_reminders").include("last_activity") self.freshBooksClient.clients.list(self.account_id, builders=[includes]) expected_params = {"include[]": ["late_reminders", "last_activity"]} assert httpretty.last_request().querystring == expected_params
def test_create_client__includes(self): url = "{}/accounting/account/{}/users/clients".format( API_BASE_URL, self.account_id) httpretty.register_uri(httpretty.POST, url, body=json.dumps( get_fixture("create_client_response")), status=200) includes = IncludesBuilder() includes.include("late_reminders").include("last_activity") payload = {"email": "*****@*****.**"} client = self.freshBooksClient.clients.create(self.account_id, payload, includes) expected_params = {"include[]": ["late_reminders", "last_activity"]} assert str(client) == "Result(client)" assert httpretty.last_request().querystring == expected_params
def test_get_client__includes(self): client_id = 12345 url = "{}/accounting/account/{}/users/clients/{}?include[]=late_reminders&include[]=last_activity".format( API_BASE_URL, self.account_id, client_id) httpretty.register_uri(httpretty.GET, url, body=json.dumps( get_fixture("get_client_response")), status=200) includes = IncludesBuilder() includes.include("late_reminders").include("last_activity") client = self.freshBooksClient.clients.get(self.account_id, client_id, includes=includes) expected_params = {"include[]": ["late_reminders", "last_activity"]} assert str(client) == "Result(client)" assert httpretty.last_request().querystring == expected_params
def test_include__project(self): includes = IncludesBuilder() includes.include("include_overdue_fees") assert includes.build( "ProjectResource") == "&include_overdue_fees=true"