def test_indexer_populates_referenced_authors_bais(inspire_app): data_authors = { "authors": [ { "full_name": "Jean-Luc Picard", "ids": [{ "schema": "INSPIRE BAI", "value": "Jean.L.Picard.1" }], }, { "full_name": "John Doe", "ids": [{ "schema": "INSPIRE BAI", "value": "J.Doe.1" }], }, ] } cited_record_1 = create_record("lit", data=data_authors) data_authors = { "authors": [ { "full_name": "Jean-Luc Picard", "ids": [{ "schema": "INSPIRE BAI", "value": "Jean.L.Picard.1" }], }, { "full_name": "Steven Johnson", "ids": [{ "schema": "INSPIRE BAI", "value": "S.Johnson.1" }], }, ] } cited_record_2 = create_record("lit", data=data_authors) citing_record = create_record( "lit", literature_citations=[ cited_record_1["control_number"], cited_record_2["control_number"], ], ) expected_rec3_referenced_authors_bais = [ "J.Doe.1", "Jean.L.Picard.1", "S.Johnson.1", ] rec1_es = LiteratureSearch.get_record_data_from_es(cited_record_1) rec2_es = LiteratureSearch.get_record_data_from_es(cited_record_2) rec3_es = LiteratureSearch.get_record_data_from_es(citing_record) assert "referenced_authors_bais" not in rec1_es assert "referenced_authors_bais" not in rec2_es assert (sorted(rec3_es["referenced_authors_bais"]) == expected_rec3_referenced_authors_bais)
def assert_disambiguation_cli(): record_from_es = LiteratureSearch.get_record_data_from_es(record) for author in record_from_es["authors"]: if author["full_name"] == "Test Author Dismabiguated": assert author["record"]["$ref"] == disambiguated_author_ref else: assert "record" in author
def test_indexer_oai_set_CERN_arxiv_and_CDS(inspire_app): extra_data = { "report_numbers": [{ "value": "CERN-2020-001" }], "arxiv_eprints": [{ "value": "2009.01484" }], "_export_to": { "CDS": True }, } record_data = faker.record("lit", data=extra_data) record = LiteratureRecord.create(record_data) record.index(delay=False) result_record = LiteratureSearch.get_record_data_from_es(record) expected_id = f"oai:inspirehep.net:{record['control_number']}" expected_updated = record.updated.strftime(OAI_TIME_FORMAT) expected_sets = [ inspire_app.config["OAI_SET_CDS"], inspire_app.config["OAI_SET_CERN_ARXIV"], ] assert expected_id == result_record["_oai"]["id"] assert expected_updated == result_record["_oai"]["updated"] assert expected_sets == result_record["_oai"]["sets"]
def assert_assign(): for literature in [literature_1, literature_2]: current_search.flush_and_refresh("*") literature_after = LiteratureSearch.get_record_data_from_es( literature) literature_author = literature_after["authors"][0] assert literature_author["record"] == { "$ref": f"http://localhost:5000/api/authors/{to_author['control_number']}" } assert literature_author["curated_relation"] assert literature_author["ids"] == to_author["ids"]
def assert_assign(): current_search.flush_and_refresh("*") literature_after = LiteratureSearch.get_record_data_from_es(literature) literature_author = literature_after["authors"][1] to_author_after = AuthorsRecord.get_record_by_pid_value( to_author["control_number"]) assert literature_author["record"] == { "$ref": f"http://localhost:5000/api/authors/{to_author['control_number']}" } assert literature_author["curated_relation"] assert literature_author["ids"] == to_author["ids"] assert not to_author_after["stub"]
def test_indexer_oai_set_CDS(inspire_app): extra_data = {"_export_to": {"CDS": True}} record_data = faker.record("lit", data=extra_data) record = LiteratureRecord.create(record_data) record.index(delay=False) result_record = LiteratureSearch.get_record_data_from_es(record) expected_id = f"oai:inspirehep.net:{record['control_number']}" expected_updated = "1994-12-19T00:00:00" expected_sets = [inspire_app.config["OAI_SET_CDS"]] assert expected_id == result_record["_oai"]["id"] assert expected_updated == result_record["_oai"]["updated"] assert expected_sets == result_record["_oai"]["sets"]
def test_indexer_oai_set_CERN_arxiv(inspire_app): extra_data = { "report_numbers": [{"value": "CERN-2020-001"}], "arxiv_eprints": [{"value": "2009.01484"}], } record_data = faker.record("lit", data=extra_data) record = LiteratureRecord.create(record_data) record.index(delay=False) result_record = LiteratureSearch.get_record_data_from_es(record) expected_id = f"oai:inspirehep.net:{record['control_number']}" expected_updated = "1994-12-19T00:00:00" expected_sets = [inspire_app.config["OAI_SET_CERN_ARXIV"]] assert expected_id == result_record["_oai"]["id"] assert expected_updated == result_record["_oai"]["updated"] assert expected_sets == result_record["_oai"]["sets"]
def test_indexer_does_not_have_oai_set(inspire_app): record_data = faker.record("lit") record = LiteratureRecord.create(record_data) record.index(delay=False) result_record = LiteratureSearch.get_record_data_from_es(record) assert "_oai" not in result_record
def assert_records_in_es(): lit_record_from_es = LiteratureSearch.get_record_data_from_es( lit_record) assert lit_record_from_es