Пример #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
Пример #2
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    record = {'abstracts': []}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Пример #3
0
def test_get_abstract_returns_empty_string_when_no_titles():
    no_abstracts = Record({})

    expected = ''
    result = get_abstract(no_abstracts)

    assert expected == result
Пример #4
0
def test_get_abstract_returns_empty_string_when_no_titles():
    no_abstracts = InspireRecord({})

    expected = ''
    result = get_abstract(no_abstracts)

    assert expected == result
Пример #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
Пример #6
0
def test_get_abstract_returns_empty_string_when_abstracts_is_empty():
    record = {'abstracts': []}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Пример #7
0
def test_get_abstract_returns_empty_string_when_no_abstracts():
    record = {}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Пример #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),
    }
Пример #9
0
def test_get_abstract_returns_empty_string_when_no_abstracts():
    record = {}

    expected = ''
    result = get_abstract(record)

    assert expected == result
Пример #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),
    }
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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),
    }
Пример #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),
    }
Пример #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
Пример #26
0
def abstract_rule(self, key, value):
    return strip_tags(get_abstract({"abstracts": value}))
Пример #27
0
def abstract_rule(self, key, value):
    return strip_tags(get_abstract({"abstracts": value}))