def test_match_reference_ignores_hidden_collections(inspire_app): cited_record_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["HAL Hidden"], "control_number": 1, "document_type": ["article"], "dois": [{"value": "10.1371/journal.pone.0188398"}], } create_record("lit", cited_record_json) reference = {"reference": {"dois": ["10.1371/journal.pone.0188398"]}} schema = load_schema("hep") subschema = schema["properties"]["references"] assert validate([reference], subschema) is None reference = match_reference(reference) assert "record" not in reference
def test_match_pubnote_info_when_journal_is_missing_a_letter(inspire_app): cited_record_with_pub_info_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["Literature"], "control_number": 1, "document_type": ["article"], "publication_info": [{ "artid": "101", "journal_title": "Phys. Rev. B.", "journal_volume": "100", "page_start": "100", "year": 2020, }], "titles": [{ "title": "The Strongly-Interacting Light Higgs" }], } create_record("lit", cited_record_with_pub_info_json) reference = { "reference": { "publication_info": { "journal_title": "Phys. Rev.", "journal_volume": "100", "page_start": "100", }, } } reference = match_reference(reference) assert reference["record"][ "$ref"] == "http://localhost:5000/api/literature/1" expected_control_number = [1] result_control_number = match_reference_control_numbers(reference) assert expected_control_number == result_control_number
def test_match_reference_finds_proper_ref_when_wrong_provided(inspire_app): cited_record_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["Literature"], "control_number": 1, "document_type": ["article"], "texkeys": ["Giudice:2007fh"], "titles": [{ "title": "The Strongly-Interacting Light Higgs" }], } create_record("lit", cited_record_json) reference = { "reference": { "texkey": "Giudice:2007fh" }, "record": { "$ref": "http://localhost:5000/api/literature/9999" }, } schema = load_schema("hep") subschema = schema["properties"]["references"] assert validate([reference], subschema) is None reference = match_reference(reference) assert reference["record"][ "$ref"] == "http://localhost:5000/api/literature/1" assert validate([reference], subschema) is None expected_control_number = [1] result_control_number = match_reference_control_numbers_with_relaxed_journal_titles( reference) assert expected_control_number == result_control_number
def test_match_reference_doesnt_touch_curated(inspire_app): cited_record_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["Literature"], "control_number": 1, "document_type": ["article"], "dois": [{ "value": "10.1371/journal.pone.0188398" }], } create_record("lit", cited_record_json) reference = { "curated_relation": True, "record": { "$ref": "http://localhost:5000/api/literature/42" }, "reference": { "dois": ["10.1371/journal.pone.0188398"] }, } schema = load_schema("hep") subschema = schema["properties"]["references"] assert validate([reference], subschema) is None reference = match_reference(reference) assert reference["record"][ "$ref"] == "http://localhost:5000/api/literature/42" expected_control_number = [42] result_control_number = match_reference_control_numbers_with_relaxed_journal_titles( reference) assert expected_control_number == result_control_number
def test_match_reference_on_texkey_has_lower_priority_than_pub_info( inspire_app): cited_record_with_texkey_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["Literature"], "control_number": 1, "document_type": ["article"], "texkeys": ["MyTexKey:2008fh"], "titles": [{ "title": "The Strongly-Interacting Light Higgs" }], } create_record("lit", cited_record_with_texkey_json) cited_record_with_pub_info_json = { "$schema": "http://localhost:5000/schemas/records/hep.json", "_collections": ["Literature"], "control_number": 2, "document_type": ["article"], "publication_info": [{ "artid": "100", "journal_title": "JHEP", "journal_volume": "100", "page_start": "100", "year": 2020, }], "titles": [{ "title": "The Strongly-Interacting Light Higgs" }], } create_record("lit", cited_record_with_pub_info_json) reference = { "reference": { "texkey": "MyTexKey:2008fh", "publication_info": { "artid": "100", "journal_title": "JHEP", "journal_volume": "100", "page_start": "100", "year": 2020, }, } } schema = load_schema("hep") subschema = schema["properties"]["references"] assert validate([reference], subschema) is None reference = match_reference(reference) assert reference["record"][ "$ref"] == "http://localhost:5000/api/literature/2" assert validate([reference], subschema) is None expected_control_number = [2, 1] result_coontrol_number = match_reference_control_numbers(reference) assert set(expected_control_number) == set(result_coontrol_number) assert len(expected_control_number) == len(result_coontrol_number)