Added testing of test_unidecode() and another name_parts() test case, and removed some debug.statements.
- Legacy-Id: 15771
This commit is contained in:
parent
69263cf141
commit
d6caf615e0
|
@ -1,3 +1,7 @@
|
|||
# Copyright The IETF Trust 2014-2018, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals, print_function
|
||||
|
||||
import os
|
||||
import factory
|
||||
import faker
|
||||
|
|
|
@ -56,7 +56,6 @@ def name_parts(name):
|
|||
if len(parts) >= 2:
|
||||
# Handle reverse-order names with uppercase surname correctly
|
||||
if re.search("^[A-Z-]+$", first):
|
||||
debug.log('6, name')
|
||||
first, last = last, first.capitalize()
|
||||
return prefix, first, middle, last, suffix
|
||||
|
||||
|
@ -113,7 +112,6 @@ def unidecode_name(uname):
|
|||
last = (last+last).capitalize()
|
||||
# Restore the particle, if any
|
||||
if particle and last.startswith(capfirst(particle)+' '):
|
||||
debug.log('7, uname')
|
||||
last = ' '.join([ particle, last[len(particle)+1:] ])
|
||||
# Recombine the parts
|
||||
parts = prefix, first, middle, last, suffix
|
||||
|
|
|
@ -31,7 +31,7 @@ import debug # pyflakes:ignore
|
|||
|
||||
from ietf.group.factories import GroupFactory
|
||||
from ietf.group.models import Group
|
||||
from ietf.person.name import name_parts
|
||||
from ietf.person.name import name_parts, unidecode_name
|
||||
from ietf.submit.tests import submission_file
|
||||
from ietf.utils.draft import Draft, getmeta
|
||||
from ietf.utils.mail import send_mail_preformatted, send_mail_text, send_mail_mime, outbox
|
||||
|
@ -446,7 +446,7 @@ class NameTests(TestCase):
|
|||
("Donald E. Eastlake 3rd", ('', 'Donald', 'E.', 'Eastlake', '3rd')),
|
||||
("Professor André Danthine", ('Professor', 'André', '', 'Danthine', '')),
|
||||
("DENG Hui", ('', 'Hui', '', 'Deng', '')),
|
||||
("", ('', '', '', '', '')),
|
||||
("ዳዊት በቀለ (Dawit Bekele)", ('', 'ዳዊት', '', 'በቀለ', '')),
|
||||
("", ('', '', '', '', '')),
|
||||
("", ('', '', '', '', '')),
|
||||
("", ('', '', '', '', '')),
|
||||
|
@ -456,3 +456,22 @@ class NameTests(TestCase):
|
|||
for name, parts in names:
|
||||
if name:
|
||||
self.assertEqual(parts, name_parts(name))
|
||||
|
||||
|
||||
def test_unidecode(self):
|
||||
names = (
|
||||
("ዳዊት በቀለ", "Daawite Baqala",),
|
||||
("丽 郜", "Li Gao"),
|
||||
("कम्बोज डार", "Kmboj Ddaar"),
|
||||
("Ηράκλεια Λιόντη", "Erakleia Lionte"),
|
||||
("ישראל רוזנפלד", "Yshrl Rvznpld"),
|
||||
("丽华 皇", "Li Hua Huang"),
|
||||
("نرگس پویان", "Nrgs Pwyn"),
|
||||
("موسوی سينا زمانی", ""),
|
||||
("", ""),
|
||||
)
|
||||
|
||||
for name, ascii in names:
|
||||
if name:
|
||||
self.assertEqual(ascii, unidecode_name(name))
|
||||
|
||||
|
|
Loading…
Reference in a new issue