Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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