Пример #1
0
def test_format_output_row_arxiv_with_publi_info():
    with_publi_info = InspireRecord(
        {'publication_info': [{
            'journal_title': ''
        }]})
    latex = Latex(with_publi_info, 'latex_eu')

    expected = u'  [arXiv:1512.01381 [hep-th]].\n'
    result = latex._format_output_row('arxiv', 'arXiv:1512.01381 [hep-th]')

    assert expected == result
Пример #2
0
def test_get_title_from_titles_not_a_list():
    titles_not_a_list = InspireRecord(
        {'titles': {
            'title': 'Partial Symmetries of Weak Interactions'
        }})
    latex = Latex(titles_not_a_list, 'latex_eu')

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

    assert expected == result
Пример #3
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 = InspireRecord(
        {'authors': [{
            'full_name': ['Englert, F.', 'Brout, R.']
        }]})
    latex = Latex(one_author_with_a_list_of_two_full_names, 'latex_eu')

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

    assert expected == result
Пример #4
0
def test_get_title_from_titles_a_list_with_one_element():
    titles_a_list_with_one_element = InspireRecord(
        {'titles': [{
            'title': 'Partial Symmetries of Weak Interactions'
        }]})
    latex = Latex(titles_a_list_with_one_element, 'latex_eu')

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

    assert expected == result
Пример #5
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 = InspireRecord(
        {'authors': [{
            'full_name': ['Glashow, S.L.']
        }]})
    latex = Latex(one_author_with_a_list_of_one_full_name, 'latex_eu')

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

    assert expected == result
Пример #6
0
def test_get_author_from_authors_one_author_with_an_empty_list_of_full_names():
    one_author_with_an_empty_list_of_full_names = InspireRecord(
        {'authors': [{
            'full_name': []
        }]})
    latex = Latex(one_author_with_an_empty_list_of_full_names, 'latex_eu')

    expected = []
    result = latex._get_author()

    assert expected == result
Пример #7
0
def test_get_author_from_authors_a_list_with_one_element():
    authors_a_list_with_one_element = InspireRecord(
        {'authors': [{
            'full_name': 'Glashow, S.L.'
        }]})
    latex = Latex(authors_a_list_with_one_element, 'latex_eu')

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

    assert expected == result
def test_ads_links_uses_preferred_name_when_name_has_no_lastname():
    without_last_name = InspireRecord(
        {'name': {
            'value': ', John R.',
            'preferred_name': 'Ellis, John R.'
        }})

    expected = 'http://adsabs.harvard.edu/cgi-bin/author_form?author=Ellis, John R.'
    result = ads_links(without_last_name)

    assert expected == result
def test_generate_booktitle_reportnumber_and_conf_acronym():
    recordnumber_and_conf_acronym = InspireRecord({
        'publication_info': [{
            'reportnumber': 'CERN-Proceedings-2010-001',
            'conf_acronym': 'FOO'  # No value in 773__o.
        }]
    })

    expected = 'CERN-Proceedings-2010-0001: FOO'
    result = generate_booktitle(recordnumber_and_conf_acronym)

    assert expected == result
Пример #10
0
def test_get_publi_info_from_publication_info_with_journal_title_a_list_of_two_elements():
    journal_title_a_list_of_two_elements = InspireRecord({
        'publication_info': [
            {'journal_title': ['foo', 'bar']}
        ]
    })
    latex = Latex(journal_title_a_list_of_two_elements, 'latex_eu')

    expected = ['bar']
    result = latex._get_publi_info()

    assert expected == result
Пример #11
0
def test_get_publi_info_from_publication_info_with_journal_title_not_a_list():
    journal_title_not_a_list = InspireRecord({
        'publication_info': [
            {'journal_title': 'Nucl.Phys.'}
        ]
    })
    latex = Latex(journal_title_not_a_list, 'latex_eu')

    expected = ['Nucl.\\ Phys.\\ ']
    result = latex._get_publi_info()

    assert expected == result
Пример #12
0
def test_get_citation_key_a_list_selects_first():
    a_list_selects_first = InspireRecord({
        'external_system_numbers': [{
            'institute': 'INSPIRETeX',
            'value': ['foo', 'bar']
        }]
    })

    expected = 'foo'
    result = Export(a_list_selects_first)._get_citation_key()

    assert expected == result
Пример #13
0
def test_get_arxiv_multiple_categories():

    multiple_categories = InspireRecord(
        {'arxiv_eprints': [{
            'value': 'foo',
            'categories': ['bar', 'baz']
        }]})

    expected = 'foo [bar,baz]'
    result = Export(multiple_categories)._get_arxiv()

    assert expected == result
Пример #14
0
def test_arxiv_field_returns_first():
    returns_first = InspireRecord(
        {'arxiv_eprints': [{
            'value': 'foo'
        }, {
            'value': 'bar'
        }]})

    expected = {'value': 'foo'}
    result = Export(returns_first).arxiv_field

    assert expected == result
Пример #15
0
def test_get_volume_from_publication_info_actually_from_book_series():
    publication_info_actually_from_book_series = InspireRecord({
        'publication_info': [],
        'book_series': [{
            'volume': '11'
        }]
    })

    expected = '11'
    result = Bibtex(publication_info_actually_from_book_series)._get_volume()

    assert expected == result
def test_get_author_from_authors_one_author_with_a_list_of_two_full_names():
    one_author_with_a_list_of_two_full_names = InspireRecord(
        {'authors': [{
            'full_name': ['Englert, F.', 'Brout, R.']
        }]})
    cv_latex_html_text = Cv_latex_html_text(
        one_author_with_a_list_of_two_full_names, 'cv_latex_html', ',')

    expected = ['F.Brout Englert, R.']
    result = cv_latex_html_text._get_author()

    assert expected == result
Пример #17
0
def test_get_citation_key_trims_spaces():
    trims_spaces = InspireRecord({
        'external_system_numbers': [{
            'institute': 'INSPIRETeX',
            'value': 'f o o'
        }]
    })

    expected = 'foo'
    result = Export(trims_spaces)._get_citation_key()

    assert expected == result
Пример #18
0
def test_get_volume_from_book_series_two_volumes():
    book_series_two_volumes = InspireRecord(
        {'book_series': [{
            'volume': '11'
        }, {
            'volume': '5'
        }]})

    expected = '5'
    result = Bibtex(book_series_two_volumes)._get_volume()

    assert expected == result
Пример #19
0
def test_get_arxiv_single_category():

    single_category = InspireRecord(
        {'arxiv_eprints': [{
            'value': 'foo',
            'categories': ['bar']
        }]})

    expected = 'foo [bar]'
    result = Export(single_category)._get_arxiv()

    assert expected == result
def test_get_title_when_titles_is_not_a_list_without_subtitles():
    titles_not_a_list_without_subtitles = InspireRecord(
        {'titles': {
            'title': 'foo'
        }})
    cv_latex_html_text = Cv_latex_html_text(
        titles_not_a_list_without_subtitles, 'cv_latex_html_text', ',')

    expected = 'foo'
    result = cv_latex_html_text._get_title()

    assert expected == result
Пример #21
0
def test_get_citation_key_no_value_no_obsolete():
    from inspirehep.utils.export import Export

    no_value_no_obsolete = InspireRecord(
        {'external_system_numbers': [{
            'institute': 'INSPIRETeX'
        }]})

    expected = ''
    result = Export(no_value_no_obsolete)._get_citation_key()

    assert expected == result
def test_get_title_capitalizes_when_title_contains_uppercase_the():
    title_contains_uppercase_the = InspireRecord(
        {'titles': [{
            'title': 'foo THE bar'
        }]})
    cv_latex_html_text = Cv_latex_html_text(title_contains_uppercase_the,
                                            'cv_latex_html_text', ',')

    expected = 'Foo The Bar'
    result = cv_latex_html_text._get_title()

    assert expected == result
Пример #23
0
def test_get_author_from_corporate_author_a_list_with_one_element():
    corporate_author_a_list_of_one_element = InspireRecord({
        'corporate_author': [
            'CMS Collaboration'
        ]
    })
    latex = Latex(corporate_author_a_list_of_one_element, 'latex_eu')

    expected = ['CMS Collaboration']
    result = latex._get_author()

    assert expected == result
def test_get_author_from_authors_a_list_with_one_element():
    authors_a_list_with_one_element = InspireRecord(
        {'authors': [{
            'full_name': 'Glashow, S.L.'
        }]})
    cv_latex_html_text = Cv_latex_html_text(authors_a_list_with_one_element,
                                            'cv_latex_html', ',')

    expected = ['S.L. Glashow']
    result = cv_latex_html_text._get_author()

    assert expected == result
Пример #25
0
def test_get_publi_info_from_publication_info_with_journal_title_an_empty_list():
    journal_title_an_empty_list = InspireRecord({
        'publication_info': [
            {'journal_title': []}
        ]
    })
    latex = Latex(journal_title_an_empty_list, 'latex_eu')

    expected = []
    result = latex._get_publi_info()

    assert expected == result
def test_get_publi_info_from_publication_info_with_journal_title():
    journal_title = InspireRecord(
        {'publication_info': [{
            'journal_title': 'Nucl.Phys.'
        }]})
    cv_latex_html_text = Cv_latex_html_text(journal_title,
                                            'cv_latex_html_text', ',')

    expected = ['Submitted to: Nucl.Phys.']
    result = cv_latex_html_text._get_publi_info()

    assert expected == result
Пример #27
0
def test_get_publi_info_from_pubinfo_freetext():
    pubinfo_freetext = InspireRecord({
        'publication_info': [
            {'pubinfo_freetext': 'Phys. Lett. 12 (1964) 132-133'}
        ]
    })
    latex = Latex(pubinfo_freetext, 'latex_eu')

    expected = 'Phys. Lett. 12 (1964) 132-133'
    result = latex._get_publi_info()

    assert expected == result
def test_get_author_from_authors_one_author_with_an_empty_list_of_full_names():
    one_author_with_an_empty_list_of_full_names = InspireRecord(
        {'authors': [{
            'full_name': []
        }]})
    cv_latex_html_text = Cv_latex_html_text(
        one_author_with_an_empty_list_of_full_names, 'cv_latex_html', ',')

    expected = []
    result = cv_latex_html_text._get_author()

    assert expected == result
def test_generate_booktitle_from_one_pubinfo_freetext():
    one_pubinfo_freetext = InspireRecord({
        'publication_info': [{
            'pubinfo_freetext':
            'Adv. Theor. Math. Phys. 2 (1998) 51-59'
        }]
    })

    expected = 'Adv. Theor. Math. Phys. 2 (1998) 51-59'
    result = generate_booktitle(one_pubinfo_freetext)

    assert expected == result
def test_get_author_from_authors_one_author_with_a_list_of_one_full_name():
    one_author_with_a_list_of_one_full_name = InspireRecord(
        {'authors': [{
            'full_name': ['Glashow, S.L.']
        }]})
    cv_latex_html_text = Cv_latex_html_text(
        one_author_with_a_list_of_one_full_name, 'cv_latex_html', ',')

    expected = ['S.L. Glashow']
    result = cv_latex_html_text._get_author()

    assert expected == result