def test_company_dbmodels_to_es_documents(self, setup_es): """Tests conversion of db models to Elasticsearch documents.""" companies = CompanyFactory.create_batch(2) result = ESCompany.db_objects_to_es_documents(companies) assert len(list(result)) == len(companies)
def test_company_dbmodels_to_documents(self, opensearch): """Tests conversion of db models to OpenSearch documents.""" companies = CompanyFactory.create_batch(2) app = get_search_app('company') companies_qs = app.queryset.all() result = SearchCompany.db_objects_to_documents(companies_qs) assert len(list(result)) == len(companies)
def test_company_dbmodel_to_dict(self, setup_es): """Tests conversion of db model to dict.""" company = CompanyFactory() result = ESCompany.db_object_to_dict(company) keys = { 'archived', 'archived_by', 'archived_on', 'archived_reason', 'business_type', 'companies_house_data', 'company_number', 'created_on', 'description', 'employee_range', 'export_experience_category', 'export_to_countries', 'future_interest_countries', 'headquarter_type', 'id', 'modified_on', 'name', 'global_headquarters', 'reference_code', 'sector', 'suggest', 'address', 'registered_address', # TODO: delete once the migration to address and registered address is complete 'registered_address_1', 'registered_address_2', 'registered_address_country', 'registered_address_county', 'registered_address_postcode', 'registered_address_town', 'trading_address_1', 'trading_address_2', 'trading_address_country', 'trading_address_county', 'trading_address_postcode', 'trading_address_town', 'trading_names', 'turnover_range', 'uk_based', 'uk_region', 'vat_number', 'duns_number', 'website', } assert set(result.keys()) == keys
def test_company_dbmodel_to_dict(self, opensearch): """Tests conversion of db model to dict.""" company = CompanyFactory() app = get_search_app('company') company_qs = app.queryset.get(pk=company.pk) result = SearchCompany.db_object_to_dict(company_qs) keys = { '_document_type', 'archived', 'archived_by', 'archived_on', 'archived_reason', 'business_type', 'company_number', 'created_on', 'description', 'employee_range', 'export_experience_category', 'export_to_countries', 'future_interest_countries', 'headquarter_type', 'id', 'modified_on', 'name', 'global_headquarters', 'reference_code', 'sector', 'latest_interaction_date', 'address', 'registered_address', 'one_list_group_global_account_manager', 'trading_names', 'turnover_range', 'uk_based', 'uk_region', 'uk_address_postcode', 'uk_registered_address_postcode', 'vat_number', 'duns_number', 'website', 'export_segment', 'export_sub_segment', } assert set(result.keys()) == keys