Skip to content

Commit d6caf61

Browse files
committed
Added testing of test_unidecode() and another name_parts() test case, and removed some debug.statements.
- Legacy-Id: 15771
1 parent 69263cf commit d6caf61

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

ietf/person/factories.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright The IETF Trust 2014-2018, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
from __future__ import unicode_literals, print_function
4+
15
import os
26
import factory
37
import faker

ietf/person/name.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def name_parts(name):
5656
if len(parts) >= 2:
5757
# Handle reverse-order names with uppercase surname correctly
5858
if re.search("^[A-Z-]+$", first):
59-
debug.log('6, name')
6059
first, last = last, first.capitalize()
6160
return prefix, first, middle, last, suffix
6261

@@ -113,7 +112,6 @@ def unidecode_name(uname):
113112
last = (last+last).capitalize()
114113
# Restore the particle, if any
115114
if particle and last.startswith(capfirst(particle)+' '):
116-
debug.log('7, uname')
117115
last = ' '.join([ particle, last[len(particle)+1:] ])
118116
# Recombine the parts
119117
parts = prefix, first, middle, last, suffix

ietf/utils/tests.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from ietf.group.factories import GroupFactory
3333
from ietf.group.models import Group
34-
from ietf.person.name import name_parts
34+
from ietf.person.name import name_parts, unidecode_name
3535
from ietf.submit.tests import submission_file
3636
from ietf.utils.draft import Draft, getmeta
3737
from ietf.utils.mail import send_mail_preformatted, send_mail_text, send_mail_mime, outbox
@@ -446,7 +446,7 @@ def test_name_parts(self):
446446
("Donald E. Eastlake 3rd", ('', 'Donald', 'E.', 'Eastlake', '3rd')),
447447
("Professor André Danthine", ('Professor', 'André', '', 'Danthine', '')),
448448
("DENG Hui", ('', 'Hui', '', 'Deng', '')),
449-
("", ('', '', '', '', '')),
449+
("ዳዊት በቀለ (Dawit Bekele)", ('', 'ዳዊት', '', 'በቀለ', '')),
450450
("", ('', '', '', '', '')),
451451
("", ('', '', '', '', '')),
452452
("", ('', '', '', '', '')),
@@ -456,3 +456,22 @@ def test_name_parts(self):
456456
for name, parts in names:
457457
if name:
458458
self.assertEqual(parts, name_parts(name))
459+
460+
461+
def test_unidecode(self):
462+
names = (
463+
("ዳዊት በቀለ", "Daawite Baqala",),
464+
("丽 郜", "Li Gao"),
465+
("कम्बोज डार", "Kmboj Ddaar"),
466+
("Ηράκλεια Λιόντη", "Erakleia Lionte"),
467+
("ישראל רוזנפלד", "Yshrl Rvznpld"),
468+
("丽华 皇", "Li Hua Huang"),
469+
("نرگس پویان", "Nrgs Pwyn"),
470+
("موسوی سينا زمانی", ""),
471+
("", ""),
472+
)
473+
474+
for name, ascii in names:
475+
if name:
476+
self.assertEqual(ascii, unidecode_name(name))
477+

0 commit comments

Comments
 (0)