def test_set_pubnote_does_not_overwrite_pubnote(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.set_pubnote('Phys.Rev.,D43,124-156') builder.set_pubnote(',12,18') expected = [ { 'reference': { 'publication_info': { 'journal_title': 'Phys.Rev.D', 'journal_volume': '43', 'page_start': '124', 'page_end': '156', }, 'misc': ['Additional pubnote: ,12,18'], }, }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result
def test_set_pubnote_puts_incomplete_pubnote_in_misc(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.set_pubnote('Phys.Rev.,D43,') expected = [ { 'reference': { 'misc': ['Phys.Rev.,D43,'] }, }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result
def test_set_pubnote_falls_back_to_misc(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.set_pubnote('not-a-valid-pubnote') expected = [ { 'reference': { 'misc': ['not-a-valid-pubnote'], }, }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result
def test_set_pubnote_falls_back_to_raw_refs(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.set_pubnote('not-a-valid-pubnote') expected = [ { 'raw_refs': [ { 'schema': 'text', 'value': 'not-a-valid-pubnote', }, ], }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result
def test_set_pubnote(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.set_pubnote('Nucl.Phys.,B360,362') expected = [ { 'reference': { 'publication_info': { 'artid': '362', 'journal_title': 'Nucl.Phys.B', 'journal_volume': '360', 'page_start': '362', }, }, }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result