def test_populate_authors_name_variations_does_nothing_if_other_schema(): schema = load_schema('hep') record = { '$schema': 'http://localhost:5000/records/schemas/hep.json', '_collections': ['Literature'], 'authors': [ { 'full_name': 'Rafelski, Johann' }, ], 'document_type': [ 'book', ], 'titles': [ { 'title': 'Relativity Matters' }, ], } record = InspireRecord(record, model=RecordMetadata) assert validate(record, schema) is None populate_authors_name_variations(record) assert 'name_variations' not in record
def test_populate_authors_name_variations(): schema = load_schema('authors') record = { '$schema': 'http://localhost:5000/records/schemas/authors.json', 'name': {'value': 'Silk, James Brian'}, '_collections': ['Authors'], } record = InspireRecord(record, model=RecordMetadata) assert validate(record, schema) is None populate_authors_name_variations(record) expected = generate_name_variations(record['name'].get('value')) result = record['name_variations'] assert expected == result
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)
def test_populate_authors_name_variations_does_nothing_if_other_schema(): schema = load_schema('hep') record = { '$schema': 'http://localhost:5000/records/schemas/hep.json', '_collections': ['Literature'], 'authors': [ {'full_name': 'Rafelski, Johann'}, ], 'document_type': [ 'book', ], 'titles': [ {'title': 'Relativity Matters'}, ], } record = InspireRecord(record, model=RecordMetadata) assert validate(record, schema) is None populate_authors_name_variations(record) assert 'name_variations' not in record