def test_indexing(mock_record, mock_indexer, mock_search, example_record): # Index document in ES assert mock_indexer.index(mock_record)["result"] == "created" # Retrieve document from ES and load the source data = mock_search(id=mock_record.id) record = Record.loads(data["_source"]) # Getting the language records should work: lang_record = list(record.relations.languages())[0] assert lang_record == example_record # Dereferencing also works record.relations.languages.dereference() deferenced_lang_record = mock_record.metadata['languages'][0] assert sorted(deferenced_lang_record.keys()) == ['id', 'title']
def test_record_indexing(app, db, es, example_record, indexer): """Test indexing of a record.""" # Index document in ES assert indexer.index(example_record)['result'] == 'created' # Retrieve document from ES data = current_search_client.get('records-record-v1.0.0', id=example_record.id, doc_type='_doc') # Loads the ES data and compare record = Record.loads(data['_source']) assert record == example_record assert record.id == example_record.id assert record.revision_id == example_record.revision_id assert record.created == example_record.created assert record.updated == example_record.updated assert record.expires_at == example_record.expires_at # Check system fields record.metadata == example_record['metadata']