def test_get_company_by_crn(test_client: ApiClient, requests_mock): requests_mock.register_uri( "GET", "/company/v2/companies", json=dict(results=[], links={}) ) requests_mock.register_uri( "GET", "/company/v2/companies?crn=test", json=GET_COMPANIES_1_PAGE_1 ) companies = [ item for sublist in get_companies(test_client, crn="test") for item in sublist ] assert len(companies) == len(GET_COMPANIES_1_PAGE_1["results"])
def test_get_companies_multiple_page(test_client_paged: ApiClient): companies = [ item for sublist in get_companies(test_client_paged) for item in sublist ] assert len(companies) == 2
def test_get_companies_empty_page(test_client: ApiClient, requests_mock): requests_mock.register_uri( "GET", "/company/v2/companies", json=dict(results=[], links={}) ) companies = [item for sublist in get_companies(test_client) for item in sublist] assert len(companies) == 0
def test_get_companies_single_page(test_client: ApiClient): companies = [item for sublist in get_companies(test_client) for item in sublist] assert len(companies) == len(GET_COMPANIES_1_PAGE_1["results"])