def test_kek_missing_value(): entry_data = { "external_system_identifiers": [{ "schema": "KEKSCAN" }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert "fulltext_links" not in serialized
def test_arxiv_missing_value(): entry_data = { "arxiv_eprints": [{ "categories": ["nucl-th"] }], "control_number": 1 } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert "fulltext_links" not in serialized
def test_internal_missing_url(current_app_mock): current_app_mock.config = {"FEATURE_FLAG_ENABLE_FILES": True} entry_data = { "documents": [{ "description": "fulltext", "fulltext": True }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert "fulltext_links" not in serialized
def test_internal_fulltext_hidden(current_app_mock): current_app_mock.config = {"FEATURE_FLAG_ENABLE_FILES": True} entry_data = { "documents": [{ "hidden": True, "fulltext": True, "url": "http://localhost:8080/api/files/url_to_file", }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert "fulltext_links" not in serialized
def test_arxiv_url(): expected_data = [{ "value": "https://arxiv.org/pdf/nucl-th/9310030", "description": "arXiv" }] entry_data = { "arxiv_eprints": [{ "categories": ["nucl-th"], "value": "nucl-th/9310030" }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert serialized["fulltext_links"] == expected_data
def test_internal_fulltext_no_description(current_s3_mock, current_app_mock): current_app_mock.config = {"FEATURE_FLAG_ENABLE_FILES": True} expected_data = [{ "description": "fulltext", "value": "http://localhost:8080/api/files/url_to_file", }] entry_data = { "documents": [{ "fulltext": True, "url": "http://localhost:8080/api/files/url_to_file" }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert serialized["fulltext_links"] == expected_data
def test_arxiv_paper_without_ads_id_gets_ads_link_with_arxiv(): expected_data = [{ "url_name": "ADS Abstract Service", "url_link": "https://ui.adsabs.harvard.edu/abs/arXiv:1909.07643", }] entry_data = { "external_system_identifiers": [], "arxiv_eprints": [{ "value": "1909.07643" }], } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert serialized["external_system_identifiers"] == expected_data
def test_documents_doesnt_contain_error_from_fulltext(current_s3_mock, current_app_mock): current_app_mock.config = {"FEATURE_FLAG_ENABLE_FILES": True} entry_data = { "documents": [{ "fulltext": False, "url": "http://localhost:8080/api/files/url_to_file", "error": { "message": "Fulltext indexing failed with message expected='>' actual='À' at offset 102005" }, }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert "_error" not in serialized
def test_kek_url(): expected_data = [{ "description": "KEK scanned document", "value": "https://lib-extopc.kek.jp/preprints/PDF/1994/9407/9407219.pdf", }] entry_data = { "external_system_identifiers": [{ "schema": "KEKSCAN", "value": "94-07-219" }], "control_number": 1, } serializer = LiteratureDetailSchema() serialized = serializer.dump(entry_data).data assert serialized["fulltext_links"] == expected_data
def test_dataset_links(): external_system_identifiers = { "external_system_identifiers": [ { "schema": "HEPDATA", "value": "hep-123" }, { "schema": "ADS", "value": "ads-id-2" }, ] } expected_data = [{ "value": "https://www.hepdata.net/record/hep-123", "description": "HEPData" }] serializer = LiteratureDetailSchema() serialized = serializer.dump(external_system_identifiers).data assert serialized["dataset_links"] == expected_data
def test_literature_is_collection_hidden(collections, expected_is_collection_hidden): serializer = LiteratureDetailSchema() serialized = serializer.dump({"_collections": collections}).data assert serialized["is_collection_hidden"] == expected_is_collection_hidden
def test_literature_detail_serializes_date_from_dictionary(): data = {"preprint_date": "2020-09-15"} expected_data = {"date": "Sep 15, 2020", "preprint_date": "2020-09-15"} serializer = LiteratureDetailSchema() serialized = serializer.dump(data).data assert serialized == expected_data
{ "name": "AUGER" }, { "name": "ALMA" }, { "name": "VLBI" }, ] # Create experiment with data: create_record_factory("exp", data=experiment_data) # Create dummy experiments: create_record_factory("exp", data={"control_number": 1_110_601}) create_record_factory("exp", data={"control_number": 1_108_514}) dumped_record = LiteratureDetailSchema().dump(record).data assert dumped_record["accelerator_experiments"] == expected_experiment def test_literature_detail_serializes_conference_info(inspire_app): conference_data = { "acronyms": ["SAIP2016"], "control_number": 1_423_473, "titles": [{ "title": "61st Annual Conference of the South African Institute of Physics" }], "urls": [{ "description":