def make_author(self, full_name, affiliations=(), roles=(), raw_affiliations=(), source=None, ids=(), emails=(), alternative_names=(), record=None, affiliations_identifiers=()): """Make a subrecord representing an author. Args: full_name(str): full name of the author. If not yet in standard Inspire form, it will be normalized. affiliations(List[str]): Inspire normalized affiliations of the author. roles(List[str]): Inspire roles of the author. raw_affiliations(List[str]): raw affiliation strings of the author. source(str): source for the affiliations when ``affiliations_normalized`` is ``False``. ids(List[Tuple[str,str]]): list of ids of the author, whose elements are of the form ``(schema, value)``. emails(List[str]): email addresses of the author. alternative_names(List[str]): alternative names of the author. record(dict): reference to the author record Returns: dict: a schema-compliant subrecord. """ builder = SignatureBuilder() builder.set_full_name(full_name) builder.set_record(record) for affiliation in affiliations: builder.add_affiliation(affiliation) for role in roles: builder.add_inspire_role(role) for raw_affiliation in raw_affiliations: builder.add_raw_affiliation(raw_affiliation, source or self.source) for id_schema, id_value in ids: if id_schema and id_value: builder.set_uid(id_value, schema=id_schema) for email in emails: builder.add_email(email) for schema, value in affiliations_identifiers: builder.add_affiliations_identifiers(value, schema=schema) for alternative_name in alternative_names: builder.add_alternative_name(alternative_name) return builder.obj
def test_add_alternative_name(subschema): expected = { 'alternative_names': [ u'Petrovich Sidorov, Ivan', u'Петрович Сидоров, Иван', ] } builder = SignatureBuilder() builder.add_alternative_name(u'Petrovich Sidorov, Ivan') builder.add_alternative_name(u'Петрович Сидоров, Иван') assert_field_valid(expected, builder.obj, 'alternative_names', subschema)