def test_is_being_harvested_on_legacy_returns_true_when_there_is_one_core_category(app): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'hep-ph', 'astro-ph.CO', 'gr-qc', ], 'value': '1609.03939', }, ], } assert validate(record['arxiv_eprints'], subschema) is None extra_config = { 'ARXIV_CATEGORIES_ALREADY_HARVESTED_ON_LEGACY': [ 'hep-ph' ] } with patch.dict(app.config, extra_config): assert is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_returns_false_otherwise(): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'math.CO', ], 'value': '1705.01122', }, ], } assert validate(record['arxiv_eprints'], subschema) is None assert not is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_uses_the_correct_capitalization(): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'astro-ph.CO', ], 'value': '1705.00502', }, ], } assert validate(record['arxiv_eprints'], subschema) is None assert is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_returns_true_when_there_is_one_core_category(): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'hep-ph', 'astro-ph.CO', 'gr-qc', ], 'value': '1609.03939', }, ], } assert validate(record['arxiv_eprints'], subschema) is None assert is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_returns_true_when_there_is_one_core_category( ): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'hep-ph', 'astro-ph.CO', 'gr-qc', ], 'value': '1609.03939', }, ], } assert validate(record['arxiv_eprints'], subschema) is None assert is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_returns_false_otherwise(): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'astro-ph.IM', 'astro-ph.CO', 'cs.DS', 'stat.ML', ], 'value': '1609.03932', }, ], } assert validate(record['arxiv_eprints'], subschema) is None assert not is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_uses_the_correct_capitalization(app): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'astro-ph.CO', ], 'value': '1705.00502', }, ], } assert validate(record['arxiv_eprints'], subschema) is None extra_config = { 'ARXIV_CATEGORIES_ALREADY_HARVESTED_ON_LEGACY': ['astro-ph.CO'] } with patch.dict(app.config, extra_config): assert is_being_harvested_on_legacy(record)
def test_is_being_harvested_on_legacy_returns_false_otherwise(app): schema = load_schema('hep') subschema = schema['properties']['arxiv_eprints'] record = { 'arxiv_eprints': [ { 'categories': [ 'math.CO', ], 'value': '1705.01122', }, ], } assert validate(record['arxiv_eprints'], subschema) is None extra_config = { 'ARXIV_CATEGORIES_ALREADY_HARVESTED_ON_LEGACY': ['astro-ph.CO'] } with patch.dict(app.config, extra_config): assert not is_being_harvested_on_legacy(record)