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

    builder = ReferenceBuilder()

    builder.add_url('10.1109/NSSMIC.2005.1596597')

    expected = [
        {
            'reference': {
                'dois': ['10.1109/NSSMIC.2005.1596597'],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
def test_add_url():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_url('http://www.muonsinc.com')

    expected = [
        {
            'reference': {
                'urls': [
                    {'value': 'http://www.muonsinc.com'},
                ],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
Пример #3
0
def test_add_url_rejects_empty_ads_id():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_url('http://adsabs.harvard.edu/abs/')

    expected = [
        {
            'reference': {
                'urls': [{
                    'value': 'http://adsabs.harvard.edu/abs/'
                }],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
Пример #4
0
def test_add_url_rejects_empty_cds_id():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_url('https://cds.cern.ch/record/')

    expected = [
        {
            'reference': {
                'urls': [{
                    'value': 'https://cds.cern.ch/record/'
                }],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
Пример #5
0
def test_add_url_handles_ads_ids():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_url('http://adsabs.harvard.edu/abs/2018ApJ...853...70U')

    expected = [
        {
            'reference': {
                'external_system_identifiers': [{
                    'schema': 'ADS',
                    'value': '2018ApJ...853...70U',
                }],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
def test_add_url_handles_cds_ids():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_url('http://cds.cern.ch/record/2310556?ln=en')

    expected = [
        {
            'reference': {
                'external_system_identifiers': [{
                    'schema': 'CDS',
                    'value': '2310556',
                }],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
Пример #7
0
def test_reference_builder_is_not_adding_doi_when_already_present():
    rb = ReferenceBuilder()
    rb.add_url('https://doi.org/10.1088/1009-0630/7/4/022')
    rb.add_uid('10.1088/1009-0630/7/4/022')

    assert rb.obj['reference']['dois'] == ['10.1088/1009-0630/7/4/022']