Exemplo n.º 1
0
def test_record_indexing(app, db, es, example_record, indexer, search_get):
    """Test indexing of a record."""
    # Index document in ES
    assert indexer.index(example_record)["result"] == "created"

    # Retrieve document from ES
    data = search_get(id=example_record.id)

    # Loads the ES data and compare
    record = Vocabulary.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

    # Check system fields - i.e reading related type object from
    assert record == example_record
    assert record.type.id == 'languages'
    assert record.type.pid_type == 'lng'

    # Check that object was recrated without hitting DB
    assert inspect(record.type).persistent is False
    Vocabulary.type.session_merge(record)
    assert inspect(record.type).persistent is True
Exemplo n.º 2
0
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("vocabularies-vocabulary-v1.0.0",
                                     id=example_record.id,
                                     doc_type="_doc")

    # Loads the ES data and compare
    record = Vocabulary.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.vocabulary_type_id == example_record.vocabulary_type_id

    # Check system fields
    assert record.metadata == example_record["metadata"]