def test_get_subtitle_returns_empty_string_when_titles_is_empty():
    empty_titles = Record({'titles': []})

    expected = ''
    result = get_subtitle(empty_titles)

    assert expected == result
Exemple #2
0
def _get_art_context(record):
    abstract = get_abstract(record)
    try:
        abstract_language = detect(abstract)
    except LangDetectException:
        abstract_language = ''

    return {
        'abstract': abstract,
        'abstract_language': abstract_language,
        'arxiv_id': get_arxiv_id(record),
        'authors': get_authors(record),
        'collaborations': get_collaborations(record),
        'divulgation': get_divulgation(record),
        'doi': get_doi(record),
        'domains': get_domains(record),
        'inspire_id': get_inspire_id(record),
        'journal_issue': get_journal_issue(record),
        'journal_title': get_journal_title(record),
        'journal_volume': get_journal_volume(record),
        'keywords': get_keywords(record),
        'language': get_language(record),
        'page_artid': get_page_artid(record),
        'peer_reviewed': get_peer_reviewed(record),
        'publication_date': get_publication_date(record),
        'subtitle': get_subtitle(record),
        'title': get_title(record),
    }
def test_get_subtitle_returns_empty_string_when_no_titles():
    no_titles = Record({})

    expected = ''
    result = get_subtitle(no_titles)

    assert expected == result
def test_get_subtitle_returns_empty_string_when_titles_is_empty():
    record = {'titles': []}

    expected = ''
    result = get_subtitle(record)

    assert expected == result
def test_get_subtitle_returns_empty_string_when_no_titles():
    record = {}

    expected = ''
    result = get_subtitle(record)

    assert expected == result
Exemple #6
0
def test_get_subtitle_returns_empty_string_when_no_titles():
    no_titles = InspireRecord({})

    expected = ''
    result = get_subtitle(no_titles)

    assert expected == result
Exemple #7
0
def test_get_subtitle_returns_empty_string_when_titles_is_empty():
    empty_titles = Record({'titles': []})

    expected = ''
    result = get_subtitle(empty_titles)

    assert expected == result
Exemple #8
0
def test_get_subtitle_returns_empty_string_when_titles_is_empty():
    record = {'titles': []}

    expected = ''
    result = get_subtitle(record)

    assert expected == result
Exemple #9
0
def test_get_subtitle_returns_empty_string_when_no_titles():
    record = {}

    expected = ''
    result = get_subtitle(record)

    assert expected == result
Exemple #10
0
def title_rule(self, key, value):
    title = get_title({"titles": value})
    if title == '':
        raise KeyError
    subtitle = get_subtitle({"titles": value})
    return {"title": title,
            "subtitle": subtitle}
Exemple #11
0
def test_get_subtitle_returns_the_only_subtitle():
    single_subtitle = InspireRecord(
        {'titles': [{
            "source": "arXiv",
            'subtitle': 'Harvest of Run 1'
        }]})

    expected = 'Harvest of Run 1'
    result = get_subtitle(single_subtitle)

    assert expected == result
def test_get_subtitle_returns_first_subtitle():
    record = {
        'titles': [
            {'subtitle': 'first subtitle'},
            {'subtitle': 'second subtitle'},
        ],
    }

    expected = 'first subtitle'
    result = get_subtitle(record)

    assert expected == result
def test_get_subtitle_returns_first_subtitle():
    record = {
        'titles': [
            {'subtitle': 'first subtitle'},
            {'subtitle': 'second subtitle'},
        ],
    }

    expected = 'first subtitle'
    result = get_subtitle(record)

    assert expected == result
def test_get_subtitle_returns_the_only_subtitle():
    single_subtitle = Record({
        'titles': [
            {
                "source": "arXiv",
                'subtitle': 'Harvest of Run 1'
            }
        ]
    })

    expected = 'Harvest of Run 1'
    result = get_subtitle(single_subtitle)

    assert expected == result
Exemple #15
0
def test_get_subtitle_returns_the_non_arxiv_subtitle():
    double_subtitle = InspireRecord({
        "titles": [{
            "subtitle":
            "Importance of a consistent choice of alpha(s) in the matching of AlpGen and Pythia"
        }, {
            "source": "arXiv",
            "subtitle": "Monte Carlo tuning in the presence of Matching"
        }],
    })

    expected = 'Importance of a consistent choice of alpha(s) in the matching of AlpGen and Pythia'
    result = get_subtitle(double_subtitle)

    assert expected == result
def test_get_subtitle_returns_the_non_arxiv_subtitle():
    double_subtitle = Record({
        "titles": [
            {
                "subtitle": "Importance of a consistent choice of alpha(s) in the matching of AlpGen and Pythia"
            },
            {
                "source": "arXiv",
                "subtitle": "Monte Carlo tuning in the presence of Matching"
            }
        ],
    })

    expected = 'Importance of a consistent choice of alpha(s) in the matching of AlpGen and Pythia'
    result = get_subtitle(double_subtitle)

    assert expected == result
def test_get_subtitle():
    schema = load_schema('hep')
    subschema = schema['properties']['titles']

    record = {
        'titles': [
            {
                'subtitle': 'A mathematical exposition',
                'title': 'The General Theory of Relativity',
            },
        ],
    }
    assert validate(record['titles'], subschema) is None

    expected = 'A mathematical exposition'
    result = get_subtitle(record)

    assert expected == result
Exemple #18
0
def _get_preprint_context(record):
    abstract = get_abstract(record)
    try:
        abstract_language = detect(abstract)
    except LangDetectException:
        abstract_language = ''

    return {
        'abstract': abstract,
        'abstract_language': abstract_language,
        'arxiv_id': get_arxiv_id(record),
        'authors': get_authors(record),
        'collaborations': get_collaborations(record),
        'divulgation': get_divulgation(record),
        'domains': get_domains(record),
        'inspire_id': get_inspire_id(record),
        'keywords': get_keywords(record),
        'language': get_language(record),
        'subtitle': get_subtitle(record),
        'title': get_title(record),
    }
Exemple #19
0
def title_rule(self, key, value):
    title = get_title({"titles": value})
    if title == '':
        raise KeyError
    subtitle = get_subtitle({"titles": value})
    return {"title": title, "subtitle": subtitle}