Пример #1
0
def test_already_harvested_returns_true_when_there_is_one_core_category():
    schema = load_schema('hep')
    subschema = schema['properties']['arxiv_eprints']

    data = {
        'arxiv_eprints': [
            {
                'categories': [
                    'hep-ph',
                    'astro-ph.CO',
                    'gr-qc',
                ],
                'value': '1609.03939',
            },
        ],
    }
    extra_data = {}
    assert validate(data['arxiv_eprints'], subschema) is None

    obj = MockObj(data, extra_data)
    eng = MockEng()

    assert already_harvested(obj, eng)

    expected = ('Record with arXiv id 1609.03939 is'
                ' already being harvested on Legacy.')
    result = obj.log._info.getvalue()

    assert expected == result
Пример #2
0
def test_already_harvested_returns_false_otherwise():
    schema = load_schema('hep')
    subschema = schema['properties']['arxiv_eprints']

    data = {
        'arxiv_eprints': [
            {
                'categories': [
                    'math.CO',
                ],
                'value': '1705.01122',
            },
        ],
    }
    extra_data = {}
    assert validate(data['arxiv_eprints'], subschema) is None

    obj = MockObj(data, extra_data)
    eng = MockEng()

    assert not already_harvested(obj, eng)

    expected = ''
    result = obj.log._info.getvalue()

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

    data = {
        'arxiv_eprints': [
            {
                'categories': [
                    'hep-ph',
                    'astro-ph.CO',
                    'gr-qc',
                ],
                'value': '1609.03939',
            },
        ],
    }
    extra_data = {}
    assert validate(data['arxiv_eprints'], subschema) is None

    obj = MockObj(data, extra_data)
    eng = MockEng()

    assert already_harvested(obj, eng)

    expected = (
        'Record with arXiv id 1609.03939 is'
        ' already being harvested on Legacy.'
    )
    result = obj.log._info.getvalue()

    assert expected == result
Пример #4
0
def test_already_harvested_returns_false_otherwise(app):
    schema = load_schema('hep')
    subschema = schema['properties']['arxiv_eprints']

    data = {
        'arxiv_eprints': [
            {
                'categories': [
                    'math.CO',
                ],
                'value': '1705.01122',
            },
        ],
    }
    extra_data = {}
    assert validate(data['arxiv_eprints'], subschema) is None

    obj = MockObj(data, extra_data)
    eng = MockEng()

    extra_config = {
        'ARXIV_CATEGORIES_ALREADY_HARVESTED_ON_LEGACY': [
            'astro-ph.CO'
        ]
    }

    with patch.dict(app.config, extra_config):
        assert not already_harvested(obj, eng)

    expected = ''
    result = obj.log._info.getvalue()

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

    data = {
        'arxiv_eprints': [
            {
                'categories': [
                    'astro-ph.IM',
                    'astro-ph.CO',
                    'cs.DS',
                    'stat.ML',
                ],
                'value': '1609.03932',
            },
        ],
    }
    extra_data = {}
    assert validate(data['arxiv_eprints'], subschema) is None

    obj = MockObj(data, extra_data)
    eng = MockEng()

    assert not already_harvested(obj, eng)

    expected = ''
    result = obj.log._info.getvalue()

    assert expected == result