def test_operation_log_es_mapping(item_lib_sion, operation_log_1_data): """Test operation log elasticsearch mapping.""" search = OperationLogsSearch() mapping = get_mapping(search.Meta.index) assert mapping OperationLog.create( operation_log_1_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) count = search.query( 'query_string', query=OperationLogOperation.CREATE ).count() assert count == 3 count = search.query( 'query_string', query=OperationLogOperation.UPDATE ).count() assert count == 4 count = search.query( 'match', **{'user_name': 'updated_user'}).\ count() assert count == 1
def test_patron_es_mapping(roles, es, lib_martigny, librarian_martigny_data_tmp): """Test patron elasticsearch mapping.""" search = PatronsSearch() mapping = get_mapping(search.Meta.index) # TODO: create of an patron assert mapping == get_mapping(search.Meta.index)
def test_local_fields_es_mapping(db, org_sion, document, local_field_sion_data): """Test local fields elasticsearch mapping.""" search = LocalFieldsSearch() mapping = get_mapping(search.Meta.index) assert mapping lofi = LocalField.create(local_field_sion_data, dbcommit=True, reindex=True, delete_pid=True) flush_index(LocalFieldsSearch.Meta.index) assert mapping == get_mapping(search.Meta.index) assert lofi == local_field_sion_data assert lofi.get('pid') == '1' lofi = LocalField.get_record_by_pid('1') assert lofi == local_field_sion_data fetched_pid = fetcher(lofi.id, lofi) assert fetched_pid.pid_value == '1' assert fetched_pid.pid_type == 'lofi' document_pid = extracted_data_from_ref(lofi.get('parent')) search = DocumentsSearch().filter('term', pid=document_pid) document = list(search.scan())[0].to_dict() for field in document['local_fields']: if field['organisation_pid'] == document_pid: assert field['fields'] ==\ local_field_sion_data['fields']['field_1']
def test_library_es_mapping(es_clear, db, library_data, organisation): """.""" search = LibrariesSearch() mapping = get_mapping(search.Meta.index) assert mapping Library.create(library_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_loan_es_mapping(es_clear, db, loan_data_tmp, item_on_loan, location, library): """.""" search = current_circulation.loan_search mapping = get_mapping(search.Meta.index) assert mapping Loan.create(loan_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_library_es_mapping(es_clear, db, lib_martigny_data, org_martigny): """Test library elasticsearch mapping.""" search = LibrariesSearch() mapping = get_mapping(search.Meta.index) assert mapping Library.create( lib_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_document_es_mapping(es, db, org_martigny, document_data_ref, item_lib_martigny, person): """Test document elasticsearch mapping.""" search = DocumentsSearch() mapping = get_mapping(search.Meta.index) assert mapping data = deepcopy(document_data_ref) Document.create(data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_location_es_mapping(es, db, library, location_data): """.""" search = LocationsSearch() mapping = get_mapping(search.Meta.index) assert mapping Location.create(location_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_mef_person_es_mapping(es_clear, db, mef_person_data_tmp): """.""" search = MefPersonsSearch() mapping = get_mapping(search.Meta.index) assert mapping MefPerson.create(mef_person_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_item_type_es_mapping(es_clear, db, organisation, item_type_data_tmp): """.""" search = ItemTypesSearch() mapping = get_mapping(search.Meta.index) assert mapping ItemType.create(item_type_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_item_type_es_mapping(es_clear, db, org_martigny, item_type_data_tmp): """Test item type elasticsearch mapping.""" search = ItemTypesSearch() mapping = get_mapping(search.Meta.index) assert mapping ItemType.create(item_type_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_location_es_mapping(es_clear, db, loc_public_martigny_data, lib_martigny, org_martigny): """Test library elasticsearch mapping.""" search = LocationsSearch() mapping = get_mapping(search.Meta.index) assert mapping Location.create( loc_public_martigny_data, dbcommit=True, reindex=True, delete_pid=True) new_mapping = get_mapping(search.Meta.index) assert mapping == new_mapping
def test_contribution_es_mapping(es_clear, db, contribution_person_data_tmp): """Test mef elasticsearch mapping.""" search = ContributionsSearch() mapping = get_mapping(search.Meta.index) assert mapping Contribution.create(contribution_person_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_patron_type_es_mapping(es_clear, db, org_martigny, patron_type_children_martigny_data): """Test patron types es mapping.""" search = PatronTypesSearch() mapping = get_mapping(search.Meta.index) assert mapping PatronType.create(patron_type_children_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_circ_policy_es_mapping(es, db, org_martigny, circ_policy_martigny_data_tmp): """Test circulation policy elasticsearch mapping.""" search = CircPoliciesSearch() mapping = get_mapping(search.Meta.index) assert mapping CircPolicy.create(circ_policy_martigny_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_budgets_es_mapping(es, db, org_martigny, budget_2017_martigny_data): """Test acquisition budget elasticsearch mapping.""" search = BudgetsSearch() mapping = get_mapping(search.Meta.index) assert mapping budget = Budget.create(budget_2017_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) budget.delete(force=True, dbcommit=True, delindex=True)
def test_holding_es_mapping(es, db, holding_lib_martigny, holding_lib_martigny_data): """Test holding elasticsearch mapping.""" search = HoldingsSearch() mapping = get_mapping(search.Meta.index) assert mapping Holding.create(holding_lib_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_patron_transaction_event_es_mapping( es, db, patron_transaction_overdue_event_martigny): """Test patron_transaction event elasticsearch mapping.""" search = PatronTransactionEventsSearch() mapping = get_mapping(search.Meta.index) assert mapping PatronTransactionEvent.create(patron_transaction_overdue_event_martigny, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_budgets_es_mapping(es, db, org_martigny, vendor_martigny_data): """Test vendors elasticsearch mapping.""" search = VendorsSearch() mapping = get_mapping(search.Meta.index) assert mapping vendor = Vendor.create(vendor_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) vendor.delete(force=True, dbcommit=True, delindex=True)
def test_document_es_mapping(db, org_martigny, document_data_tmp, item_lib_martigny): """Test document elasticsearch mapping.""" search = DocumentsSearch() mapping = get_mapping(search.Meta.index) assert mapping Document.create(document_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_document_es_mapping(es_clear, db, organisation, document_data_tmp, item_on_loan): """.""" search = DocumentsSearch() mapping = get_mapping(search.Meta.index) assert mapping Document.create(document_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_item_es_mapping(es_clear, db, document, location, item_type, item_on_loan_data_tmp): """.""" search = ItemsSearch() mapping = get_mapping(search.Meta.index) assert mapping Item.create(item_on_loan_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_collections_es_mapping(es, db, org_martigny, coll_martigny_1_data, item_lib_martigny, item2_lib_martigny): """Test collections elasticsearch mapping.""" search = CollectionsSearch() mapping = get_mapping(search.Meta.index) assert mapping collection = Collection.create(coll_martigny_1_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) collection.delete(force=True, dbcommit=True, delindex=True)
def test_ill_request_es_mapping(es, db, loc_public_martigny, patron_martigny, ill_request_martigny_data): """Test ill request elasticsearch mapping.""" search = ILLRequestsSearch() mapping = get_mapping(search.Meta.index) assert mapping request = ILLRequest.create(ill_request_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) request.delete(force=True, dbcommit=True, delindex=True)
def test_local_field_es_mapping(es, db, org_martigny, document, local_field_martigny_data): """Test local field elasticsearch mapping.""" search = LocalFieldsSearch() mapping = get_mapping(search.Meta.index) assert mapping lf = LocalField.create(local_field_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) lf.delete(force=True, dbcommit=True, delindex=True)
def test_acq_accounts_es_mapping(es, db, acq_account_fiction_martigny_data, budget_2020_martigny, lib_martigny): """Test acquisition account elasticsearch mapping.""" search = AcqAccountsSearch() mapping = get_mapping(search.Meta.index) assert mapping account = AcqAccount.create(acq_account_fiction_martigny_data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index) account.delete(force=True, dbcommit=True, delindex=True)
def test_circ_policy_es_mapping(es, db, organisation, circ_policy_data_tmp): """.""" search = CircPoliciesSearch() mapping = get_mapping(search.Meta.index) assert mapping CircPolicy.create( circ_policy_data_tmp, dbcommit=True, reindex=True, delete_pid=True ) assert mapping == get_mapping(search.Meta.index)
def test_document_es_mapping(mock_contributions_mef_get, es, db, org_martigny, document_data_ref, item_lib_martigny, contribution_person_response_data): """Test document elasticsearch mapping.""" search = DocumentsSearch() mapping = get_mapping(search.Meta.index) assert mapping data = deepcopy(document_data_ref) mock_contributions_mef_get.return_value = mock_response( json_data=contribution_person_response_data) Document.create(data, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_item_es_mapping(document, loc_public_martigny, item_type_standard_martigny, item_lib_martigny_data_tmp): """Test item elasticsearch mapping.""" search = ItemsSearch() mapping = get_mapping(search.Meta.index) assert mapping Item.create(item_lib_martigny_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_notification_es_mapping(dummy_notification, loan_validated_martigny): """Test notification elasticsearch mapping.""" search = NotificationsSearch() mapping = get_mapping(search.Meta.index) assert mapping notif = deepcopy(dummy_notification) validated_pid = loan_validated_martigny.get('pid') loan_ref = f'https://bib.rero.ch/api/loans/{validated_pid}' notif['context']['loan']['$ref'] = loan_ref Notification.create(notif, dbcommit=True, delete_pid=True, reindex=True) assert mapping == get_mapping(search.Meta.index)
def get_mapping(self): if not self.mapping: self.mapping = mapping = utils.get_mapping(self.queryset) mapping['queryset'] = self.queryset mapping['create_missing'] = ( self.create_missing or mapping.get('create_missing', False) ) return self.mapping