Ejemplo n.º 1
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    empty_abstracts = Record({'abstracts': []})

    expected = ''
    result = get_abstract(empty_abstracts)

    assert expected == result
Ejemplo n.º 2
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    record = {'abstracts': []}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 3
0
def test_get_abstract_returns_empty_string_when_no_titles():
    no_abstracts = Record({})

    expected = ''
    result = get_abstract(no_abstracts)

    assert expected == result
Ejemplo n.º 4
0
def test_get_abstract_returns_empty_string_when_no_titles():
    no_abstracts = InspireRecord({})

    expected = ''
    result = get_abstract(no_abstracts)

    assert expected == result
Ejemplo n.º 5
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    empty_abstracts = InspireRecord({'abstracts': []})

    expected = ''
    result = get_abstract(empty_abstracts)

    assert expected == result
Ejemplo n.º 6
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    record = {'abstracts': []}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 7
0
def test_get_abstract_returns_empty_string_when_no_abstracts():
    record = {}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 8
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),
    }
Ejemplo n.º 9
0
def test_get_abstract_returns_empty_string_when_no_abstracts():
    record = {}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 10
0
def _build_publication(record):
    return {
        'abstract': get_abstract(record),
        'authors': _get_authors(record),
        'collaborations': get_collaborations(record),
        'keywords': get_keywords(record),
        'publication_id': record['control_number'],
        'title': get_title(record),
        'topics': get_inspire_categories(record),
    }
Ejemplo n.º 11
0
def test_get_abstract_returns_the_only_abstract():
    single_abstract = InspireRecord(
        {"abstracts": [{
            "source": "arXiv",
            "value": "abstract",
        }]})

    expected = 'abstract'
    result = get_abstract(single_abstract)

    assert expected == result
Ejemplo n.º 12
0
def test_get_abstract_returns_last_abstract_without_a_source():
    record = {
        'abstracts': [
            {'value': 'first abstract without a source'},
            {'value': 'last abstract without a source'},
        ],
    }

    expected = 'last abstract without a source'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 13
0
def test_get_abstract_returns_last_abstract_without_a_source():
    record = {
        'abstracts': [
            {'value': 'first abstract without a source'},
            {'value': 'last abstract without a source'},
        ],
    }

    expected = 'last abstract without a source'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 14
0
def test_get_abstract_returns_the_only_abstract():
    single_abstract = Record({
        "abstracts": [
            {
                "source": "arXiv",
                "value": "abstract",
            }
        ]
    })

    expected = 'abstract'
    result = get_abstract(single_abstract)

    assert expected == result
Ejemplo n.º 15
0
def test_get_abstract_returns_the_non_arxiv_abstract():
    double_abstract = InspireRecord({
        "abstracts": [{
            "source": "arXiv",
            "value": "arXiv abstract"
        }, {
            "value": "abstract"
        }]
    })

    expected = 'abstract'
    result = get_abstract(double_abstract)

    assert expected == result
Ejemplo n.º 16
0
def test_get_abstract_falls_back_to_first_abstract_even_if_from_arxiv():
    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'abstract with source arXiv',
            },
        ],
    }

    expected = 'abstract with source arXiv'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 17
0
def test_get_abstract_falls_back_to_first_abstract_even_if_from_arxiv():
    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'abstract with source arXiv',
            },
        ],
    }

    expected = 'abstract with source arXiv'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 18
0
def test_get_abstract_with_multiple_sources_returns_the_non_arxiv_abstract():
    double_abstract = Record({
        "abstracts": [{
            "source": "arXiv",
            "value": "arXiv abstract"
        }, {
            "source": "other",
            "value": "abstract"
        }]
    })

    expected = 'abstract'
    result = get_abstract(double_abstract)

    assert expected == result
Ejemplo n.º 19
0
def test_get_abstract_returns_the_non_arxiv_abstract():
    double_abstract = Record({
        "abstracts": [
            {
                "source": "arXiv",
                "value": "arXiv abstract"
            },
            {
                "value": "abstract"
            }
        ]
    })

    expected = 'abstract'
    result = get_abstract(double_abstract)

    assert expected == result
Ejemplo n.º 20
0
def test_get_abstract_returns_first_abstract_with_source_not_arxiv():
    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'abstract with source arXiv',
            },
            {
                'source': 'not arXiv',
                'value': 'abstract with source not arXiv',
            },
        ],
    }

    expected = 'abstract with source not arXiv'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 21
0
def test_get_abstract_returns_first_abstract_with_source_not_arxiv():
    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'abstract with source arXiv',
            },
            {
                'source': 'not arXiv',
                'value': 'abstract with source not arXiv',
            },
        ],
    }

    expected = 'abstract with source not arXiv'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 22
0
def test_get_abstract():
    schema = load_schema('hep')
    subschema = schema['properties']['abstracts']

    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'Probably not.',
            },
        ],
    }
    assert validate(record['abstracts'], subschema) is None

    expected = 'Probably not.'
    result = get_abstract(record)

    assert expected == result
Ejemplo n.º 23
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),
    }
Ejemplo n.º 24
0
def _get_comm_context(record):
    abstract = get_abstract(record)
    try:
        abstract_language = detect(abstract)
    except LangDetectException:
        abstract_language = ''

    conference_record = get_conference_record(record)
    conference_city = get_conference_city(conference_record)
    conference_country = get_conference_country(conference_record)
    conference_end_date = get_conference_end_date(conference_record)
    conference_start_date = get_conference_start_date(conference_record)
    conference_title = get_conference_title(conference_record)

    return {
        'abstract': abstract,
        'abstract_language': abstract_language,
        'arxiv_id': get_arxiv_id(record),
        'authors': get_authors(record),
        'collaborations': get_collaborations(record),
        'conference_city': conference_city,
        'conference_country': conference_country,
        'conference_end_date': conference_end_date,
        'conference_start_date': conference_start_date,
        'conference_title': conference_title,
        '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),
        'title': get_title(record),
    }
Ejemplo n.º 25
0
def test_get_abstract_returns_first_abstract():
    schema = load_schema('hep')
    subschema = schema['properties']['abstracts']

    record = {
        'abstracts': [
            {
                'source': 'arXiv',
                'value': 'first abstract',
            },
            {
                'source': 'publisher',
                'value': 'second abstract',
            },
        ],
    }

    expected = 'first abstract'
    result = get_abstract(record)

    assert validate(record['abstracts'], subschema) is None
    assert expected == result
Ejemplo n.º 26
0
def abstract_rule(self, key, value):
    return strip_tags(get_abstract({"abstracts": value}))
Ejemplo n.º 27
0
def abstract_rule(self, key, value):
    return strip_tags(get_abstract({"abstracts": value}))