def authed_supplier(): """ This fixture is used by sso_session_request_active_user fixture to ensure that core.authentication.SessionAuthenticationSSO authenticates. """ return SupplierFactory.create(sso_id=999)
def test_get_published_companies_use_optional_filters( authed_client, limit, minimal_number_of_sectors, expected_number_of_results): sectors_1 = ['AEROSPACE', 'AUTOMOTIVE', 'DEFENCE'] sectors_2 = ['AEROSPACE', 'AUTOMOTIVE'] company_1 = factories.CompanyFactory( is_published_investment_support_directory=True, sectors=sectors_1) company_2 = factories.CompanyFactory( is_published_investment_support_directory=True, sectors=sectors_2) supplier_1 = SupplierFactory.create(sso_id=777) supplier_2 = SupplierFactory.create(sso_id=888) supplier_1.company = company_1 supplier_1.save() supplier_2.company = company_2 supplier_2.save() url = reverse('published_companies') params = {} if limit is not None: params.update({'limit': limit}) if minimal_number_of_sectors is not None: params.update({'minimal_number_of_sectors': minimal_number_of_sectors}) response = authed_client.get(url, data=params) assert len(response.json()) == expected_number_of_results