Exemplo n.º 1
0
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
Exemplo n.º 2
0
def test_reference_builder_is_not_creating_author_empty_list_when_authors_missing(
):
    rb = ReferenceBuilder()
    rb.add_author(" ")
    rb.add_author("    ")
    assert 'reference' not in rb.obj

    rb.add_title("Title")
    rb.add_author("      ")

    assert 'authors' not in rb.obj['reference']
def test_add_title():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_title('The CMS experiment at the CERN LHC')

    expected = [
        {
            'reference': {
                'title': {
                    'title': 'The CMS experiment at the CERN LHC',
                }
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result