def test_add_author():
    schema = load_schema('hep')
    subschema = schema['properties']['references']

    builder = ReferenceBuilder()

    builder.add_author('Cox, Brian')

    expected = [
        {
            'reference': {
                'authors': [
                    {'full_name': 'Cox, Brian'},
                ],
            },
        },
    ]
    result = [builder.obj]

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

    builder = ReferenceBuilder()

    builder.add_author("O'Brian, Dara", 'ed.')

    expected = [
        {
            'reference': {
                'authors': [
                    {
                        'full_name': "O'Brian, Dara",
                        'inspire_role': 'editor',
                    },
                ],
            },
        },
    ]
    result = [builder.obj]

    assert validate(result, subschema) is None
    assert expected == result
Beispiel #3
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']