Added a bit of name normalization for test factory person names.
- Legacy-Id: 15888
This commit is contained in:
parent
97db43d011
commit
5abcec4441
|
@ -17,7 +17,7 @@ from django.utils.text import slugify
|
|||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.person.models import Person, Alias, Email
|
||||
from ietf.person.name import unidecode_name
|
||||
from ietf.person.name import normalize_name, unidecode_name
|
||||
|
||||
|
||||
fake = faker.Factory.create()
|
||||
|
@ -53,7 +53,7 @@ class PersonFactory(factory.DjangoModelFactory):
|
|||
model = Person
|
||||
|
||||
user = factory.SubFactory(UserFactory)
|
||||
name = factory.LazyAttribute(lambda p: u'%s %s'%(p.user.first_name,p.user.last_name))
|
||||
name = factory.LazyAttribute(lambda p: normalize_name(u'%s %s'%(p.user.first_name, p.user.last_name)))
|
||||
ascii = factory.LazyAttribute(lambda p: unicode(unidecode_name(p.name)))
|
||||
|
||||
class Params:
|
||||
|
|
|
@ -119,6 +119,12 @@ def unidecode_name(uname):
|
|||
name = re.sub(' +', ' ', name)
|
||||
return name
|
||||
|
||||
def normalize_name(s):
|
||||
# There is probably more to be done here, but we start by normalising
|
||||
# spaces:
|
||||
s = re.sub(' +', ' ', s)
|
||||
return s
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
name = u" ".join(sys.argv[1:])
|
||||
|
|
Loading…
Reference in a new issue