Example #1
0
def test_populate_number_references_does_nothing_if_references_is_none():
    record = {
        '$schema': 'http://localhost:5000/records/schemas/hep.json',
    }
    record = InspireRecord(record, model=RecordMetadata)
    populate_number_of_references(record)

    assert 'number_of_references' not in record
def test_populate_number_references_does_nothing_if_references_is_none():
    record = {
        '$schema': 'http://localhost:5000/records/schemas/hep.json',
    }
    record = InspireRecord(record, model=RecordMetadata)
    populate_number_of_references(record)

    assert 'number_of_references' not in record
Example #3
0
def test_populate_number_references():
    record = {
        '$schema': 'http://localhost:5000/records/schemas/hep.json',
        'references': [{
            'reference': {
                'label': '1'
            }
        }]
    }
    record = InspireRecord(record, model=RecordMetadata)
    populate_number_of_references(record)

    expected = 1
    result = record['number_of_references']

    assert expected == result
def test_populate_number_references():
    record = {
        '$schema': 'http://localhost:5000/records/schemas/hep.json',
        'references': [
            {
                'reference': {
                    'label': '1'
                }
            }
        ]
    }
    record = InspireRecord(record, model=RecordMetadata)
    populate_number_of_references(record)

    expected = 1
    result = record['number_of_references']

    assert expected == result
Example #5
0
def enhance_before_index(record):
    """Run all the receivers that enhance the record for ES in the right order.

    .. note::

       ``populate_recid_from_ref`` **MUST** come before ``populate_bookautocomplete``
       because the latter puts a JSON reference in a completion _source, which
       would be expanded to an incorrect ``_source_recid`` by the former.

    """
    populate_recid_from_ref(record)

    if is_hep(record):
        populate_abstract_source_suggest(record)
        populate_earliest_date(record)
        populate_author_count(record)
        populate_authors_full_name_unicode_normalized(record)
        populate_inspire_document_type(record)
        populate_name_variations(record)
        populate_number_of_references(record)
        populate_citations_count(record)
        populate_facet_author_name(record)
        populate_ui_display(record, RecordMetadataSchemaV1)

        if is_book(record):
            populate_bookautocomplete(record)

    elif is_author(record):
        populate_authors_name_variations(record)
        populate_author_suggest(record)

    elif is_institution(record):
        populate_affiliation_suggest(record)

    elif is_experiment(record):
        populate_experiment_suggest(record)

    elif is_journal(record):
        populate_title_suggest(record)

    elif is_data(record):
        populate_citations_count(record)