def test_add_raw_reference_with_source(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.add_raw_reference('Phys. Rev. C 80 (doi:10.1103/' 'PhysRevC.80.044313)', 'arXiv') expected = [ { 'raw_refs': [ { 'schema': 'text', 'source': 'arXiv', 'value': 'Phys. Rev. C 80 (doi:10.1103/' 'PhysRevC.80.044313)', }, ], }, ] result = [builder.obj] assert validate(result, subschema) is None assert expected == result
def test_reference_builder_skip_authors_without_full_names(): rb = ReferenceBuilder() rb.add_refextract_authors_str("Author 1, ,Author 2") rb.add_raw_reference("Author 1, , Author 2, Some Title"), rb.add_title("Some title") expected_authors = [{'full_name': '1, Author'}, {'full_name': '2, Author'}] assert len(rb.obj['reference']['authors']) assert rb.obj['reference']['authors'] == expected_authors
def test_pop_additional_pubnotes_includes_raw_ref(): schema = load_schema('hep') subschema = schema['properties']['references'] builder = ReferenceBuilder() builder.add_misc("Additional pubnote: J.Testing,42,R477") builder.add_raw_reference("A raw ref") expected_raw_refs = [ { 'schema': 'text', 'value': 'A raw ref' }, ] expected = [ { 'reference': { 'publication_info': { 'journal_title': 'J.Testing', 'journal_volume': '42', 'page_start': 'R477', 'artid': 'R477' }, 'misc': [ 'Additional pubnote split from previous reference', ], }, 'raw_refs': expected_raw_refs, }, ] result = list(builder.pop_additional_pubnotes()) assert validate(result, subschema) is None assert expected == result assert 'misc' not in builder.obj['reference'] assert builder.obj['raw_refs'] == expected_raw_refs