예제 #1
0
def test_get_author_from_authors_one_author_with_a_list_of_two_full_names():
    one_author_with_a_list_of_two_full_names = Record(
        {'authors': [{
            'full_name': ['Englert, F.', 'Brout, R.']
        }]})

    expected = ['F.~B.~Englert, R.']
    result = Cv_latex(one_author_with_a_list_of_two_full_names)._get_author()

    assert expected == result
def test_get_address_a_list_of_imprints_with_one_place_a_list():
    a_list_of_imprints_with_one_place_a_list = Record(
        {'imprints': [{
            'place': ['Moscow', 'Russia']
        }]})

    expected = 'Moscow'
    result = Bibtex(a_list_of_imprints_with_one_place_a_list)._get_address()

    assert expected == result
def test_get_entry_type_proceedings_no_pubinfo():
    proceedings_no_pubinfo = Record(
        {'collections': [{
            'primary': 'proceedings'
        }]})

    expected = ('proceedings', 'proceedings')
    result = Bibtex(proceedings_no_pubinfo)._get_entry_type()

    assert expected == result
def test_get_editor_no_author_has_editor_role():
    no_author_has_editor_role = Record({
        'authors': [{
            'full_name': 'Englert, F.'
        }, {
            'full_name': 'Brout, R.'
        }]
    })

    assert Bibtex(no_author_has_editor_role)._get_editor() is None
def test_get_entry_type_conferencepaper_no_pubinfo():
    conferencepaper_no_pubinfo = Record(
        {'collections': [{
            'primary': 'conferencepaper'
        }]})

    expected = ('inproceedings', 'inproceedings')
    result = Bibtex(conferencepaper_no_pubinfo)._get_entry_type()

    assert expected == result
def test_get_series_one_book_series():
    one_book_series = Record(
        {'book_series': [{
            'value': 'Mathematical Physics Studies'
        }]})

    expected = 'Mathematical Physics Studies'
    result = Bibtex(one_book_series)._get_series()

    assert expected == result
def test_get_author_one_author_with_one_fullname():
    one_author_with_one_fullname = Record(
        {'authors': [{
            'full_name': 'Higgs, Peter W.'
        }]})

    expected = ['Higgs, Peter W.']
    result = Bibtex(one_author_with_one_fullname)._get_author()

    assert expected == result
예제 #8
0
def test_get_citation_number_one_citation(g_e_r, strftime):
    strftime.return_value = '02 Feb 1993'
    g_e_r.return_value = {'citation_count': 1}

    one_citation = Record({'control_number': 1})

    expected = '1 citation counted in INSPIRE as of 02 Feb 1993'
    result = Export(one_citation)._get_citation_number()

    assert expected == result
예제 #9
0
def test_get_citation_number_two_citations(g_e_r, strftime):
    strftime.return_value = '02 Feb 1993'
    g_e_r.return_value = {'citation_count': 2}

    two_citations = Record({'control_number': 1})

    expected = '2 citations counted in INSPIRE as of 02 Feb 1993'
    result = Export(two_citations)._get_citation_number()

    assert expected == result
예제 #10
0
def test_types(minimal_record, recid_pid):
    """"Test contributors."""
    minimal_record.update({
        'resource_type': {
            'type': 'publication',
            'subtype': 'conferencepaper'
        }
    })
    obj = dc_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['types'] == ['info:eu-repo/semantics/conferencePaper']
예제 #11
0
def test_format_output_row_publi_info_a_list_with_one_element():
    record = Record({})
    latex = Latex(record, 'latex_eu')

    expected = u'  Phys.\\ Rev.\\ D {\\bf 73} (2006) 014022\n'
    result = latex._format_output_row('publi_info', [
        'Phys.\\ Rev.\\ D {\\bf 73} (2006) 014022'
    ])

    assert expected == result
예제 #12
0
def test_publishers(minimal_record, recid_pid):
    """Test publishers."""
    minimal_record.update({
        'part_of': {
            'publisher': 'Zenodo'
        },
    })
    obj = dc_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['publishers'] == ['Zenodo']
    minimal_record.update({
        'imprint': {
            'publisher': 'Invenio'
        },
        'part_of': {
            'publisher': 'Zenodo'
        },
    })
    obj = dc_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['publishers'] == ['Invenio']
예제 #13
0
def test_embargo_date(minimal_record, recid_pid):
    """"Test embargo date."""
    dt = (datetime.utcnow().date() + timedelta(days=1)).isoformat()
    minimal_record.update({
        'embargo_date': dt,
        'access_right': 'embargoed',
    })
    obj = dc_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['rights'] == ['info:eu-repo/semantics/embargoedAccess']
    assert 'info:eu-repo/date/embargoEnd/{0}'.format(dt) in obj['dates']
예제 #14
0
def test_esdumper_without_model(testapp, db, example_data):
    """Test the Elasticsearch dumper."""
    # Dump without a model.
    dump = Record(example_data).dumps(dumper=ElasticsearchDumper())
    for k in ['uuid', 'version_id', 'created', 'updated']:
        assert dump[k] is None  # keys is set to none without a model
    # Load without a model defined
    record = Record.loads(dump, loader=ElasticsearchDumper())
    assert record.model is None  # model will not be set
    assert record == example_data  # data is equivalent to initial data
def test_get_eprint_arxiv_field_does_not_start_with_arxiv():
    does_not_start_with_arxiv = Record(
        {'arxiv_eprints': [{
            'value': '1512.01381'
        }]})

    expected = '1512.01381'
    result = Bibtex(does_not_start_with_arxiv)._get_eprint()

    assert expected == result
예제 #16
0
def test_conference_date_formats_date_when_same_year_same_month():
    same_year_same_month = Record({
        'opening_date': '2015-03-14',
        'closing_date': '2015-03-21'
    })

    expected = '14-21 Mar 2015'
    result = conference_date(same_year_same_month)

    assert expected == result
def test_get_primary_class_one_arxiv_eprint_more_categories():
    one_arxiv_eprint_more_categories = Record(
        {'arxiv_eprints': [{
            'categories': ['hep-th', 'hep-ph']
        }]})

    expected = 'hep-th'
    result = Bibtex(one_arxiv_eprint_more_categories)._get_primary_class()

    assert expected == result
예제 #18
0
def test_conference_date_formats_date_when_same_year_different_month():
    same_year_different_month = Record({
        'opening_date': '2012-05-28',
        'closing_date': '2012-06-01'
    })

    expected = '28 May - 01 Jun 2012'
    result = conference_date(same_year_different_month)

    assert expected == result
def test_fetch_fields_missing_required_key(self, _get_key):
    _get_key.return_value = None

    from inspirehep.utils.export import MissingRequiredFieldError

    dummy = Record({})

    with pytest.raises(MissingRequiredFieldError) as excinfo:
        Bibtex(dummy)._fetch_fields(['key'], [])
    assert 'key' in str(excinfo.value)
예제 #20
0
def test_conference_date_formats_date_when_different_year():
    different_year = Record({
        'opening_date': '2012-12-31',
        'closing_date': '2013-01-01'
    })

    expected = '31 Dec 2012 - 01 Jan 2013'
    result = conference_date(different_year)

    assert expected == result
def test_get_entry_type_no_primary_collections_no_pubinfo():
    no_primary_collections_no_pubinfo = Record(
        {'collections': [{
            'not-primary': 'foo'
        }]})

    expected = ('article', 'article')
    result = Bibtex(no_primary_collections_no_pubinfo)._get_entry_type()

    assert expected == result
예제 #22
0
def test_type(app, minimal_record, recid_pid):
    """"Test type."""
    minimal_record.update({
        'resource_type': {'type': 'publication', 'subtype': 'thesis'}
    })
    obj = csl_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['type'] == 'thesis'

    minimal_record.update({
        'resource_type': {'type': 'publication'}
    })
    obj = csl_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['type'] == 'article'

    minimal_record.update({
        'resource_type': {'type': 'image'}
    })
    obj = csl_v1.transform_record(recid_pid, Record(minimal_record))
    assert obj['type'] == 'graphic'
def test_get_title_one_title():
    one_title = Record(
        {'titles': {
            'title': 'Partial Symmetries of Weak Interactions'
        }})

    expected = 'Partial Symmetries of Weak Interactions'
    result = Bibtex(one_title)._get_title()

    assert expected == result
예제 #24
0
def test_get_author_from_corporate_author_a_list_with_two_elements():
    corporate_author_a_list_of_two_elements = Record(
        {'corporate_author': ['CMS Collaboration', 'The ATLAS Collaboration']})
    cv_latex_html_text = Cv_latex_html_text(
        corporate_author_a_list_of_two_elements, 'cv_latex_html_text', ',')

    expected = ['CMS Collaboration', 'The ATLAS Collaboration']
    result = cv_latex_html_text._get_author()

    assert expected == result
def test_get_collaboration_malformed_collaboration():
    malformed_collaboration = Record(
        {'collaboration': [{
            'notvalue': 'ATLAS'
        }]})

    expected = ''
    result = Bibtex(malformed_collaboration)._get_collaboration()

    assert expected == result
def test_get_url_one_url_not_to_an_image():
    one_url_not_to_an_image = Record(
        {'urls': [{
            'value': 'http://link.aps.org/abstract/PRL/V19/P1264'
        }]})

    expected = 'http://link.aps.org/abstract/PRL/V19/P1264'
    result = Bibtex(one_url_not_to_an_image)._get_url()

    assert expected == result
def test_get_year_from_publication_info_a_list_one_year():
    publication_info_a_list_one_year = Record(
        {'publication_info': [{
            'year': '2015'
        }]})

    expected = '2015'
    result = Bibtex(publication_info_a_list_one_year)._get_year()

    assert expected == result
def test_get_eprint_arxiv_field_starts_with_arxiv():
    starts_with_arxiv = Record(
        {'arxiv_eprints': [{
            'value': 'arXiv:1512.01381'
        }]})

    expected = '1512.01381'
    result = Bibtex(starts_with_arxiv)._get_eprint()

    assert expected == result
def test_get_year_from_publication_info_a_list_from_preprint_date():
    publication_info_a_list_from_preprint_date = Record({
        'publication_info': [],
        'preprint_date': ['2015-12-04']
    })

    expected = '2015'
    result = Bibtex(publication_info_a_list_from_preprint_date)._get_year()

    assert expected == result
예제 #30
0
def test_get_author_from_authors_one_author_with_a_list_of_one_full_name():
    one_author_with_a_list_of_one_full_name = Record(
        {'authors': [{
            'full_name': ['Glashow, S.L.']
        }]})

    expected = ['S.~L.~Glashow']
    result = Cv_latex(one_author_with_a_list_of_one_full_name)._get_author()

    assert expected == result