-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_names.py
42 lines (29 loc) · 1.42 KB
/
test_names.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from names import (NAMES, dedup_and_title_case_names,
sort_by_surname_desc, shortest_first_name)
PY_CONTENT_CREATORS = ['brian okken', 'michael kennedy', 'trey hunner',
'matt harrison', 'julian sequeira', 'dan bader',
'michael kennedy', 'brian okken', 'dan bader']
def test_dedup_and_title_case_names():
names = dedup_and_title_case_names(NAMES)
assert names.count('Bob Belderbos') == 1
assert names.count('julian sequeira') == 0
assert names.count('Brad Pitt') == 1
assert len(names) == 10
assert all(n.title() in names for n in NAMES)
def test_dedup_and_title_case_names_different_names_list():
actual = sorted(dedup_and_title_case_names(PY_CONTENT_CREATORS))
expected = ['Brian Okken', 'Dan Bader', 'Julian Sequeira',
'Matt Harrison', 'Michael Kennedy', 'Trey Hunner']
assert actual == expected
def test_sort_by_surname_desc():
names = sort_by_surname_desc(NAMES)
assert names[0] == 'Julian Sequeira'
assert names[-1] == 'Alec Baldwin'
def test_sort_by_surname_desc_different_names_list():
names = sort_by_surname_desc(PY_CONTENT_CREATORS)
assert names[0] == 'Julian Sequeira'
assert names[-1] == 'Dan Bader'
def test_shortest_first_name():
assert shortest_first_name(NAMES) == 'Al'
def test_shortest_first_name_different_names_list():
assert shortest_first_name(PY_CONTENT_CREATORS) == 'Dan'