forked from daviddrysdale/python-phonenumbers
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdialpad_tests.py
More file actions
75 lines (65 loc) · 2.73 KB
/
dialpad_tests.py
File metadata and controls
75 lines (65 loc) · 2.73 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import phonenumbers
# Fixed by Phonenumbers Cases
valid_strings = ['+442083661177',
'+658003211137',
'+20573925008',
'+2057392500',
'+20225777444',
'+84384813220',
'+84357659677',
'+56232512653', # https://switchcomm.atlassian.net/browse/TEL-9285
'+525547808256',
'+13677395285',
'+16892226575',
'+18404440531',
'+48477314848',
'+6569786318',
'+6560115374', # https://switchcomm.atlassian.net/browse/TEL-14616
'+576015088865', # https://switchcomm.atlassian.net/browse/TEL-14616
'+5715088865', # https://switchcomm.atlassian.net/browse/TEL-14616
]
print '######### - VALID BY LIBRARY - ################'
for l in valid_strings:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x
# To be fixed by Dialpad Changes
dialpad_cases = ['+6278033212174', # https://switchcomm.atlassian.net/browse/DP-13742
'+63283168971', # Philipines
'+8031000000141', # Dialpadistan
'+2250757715034', # Ivory Coast - New Format
'+2252721214601', # Ivory Coast - New Format
]
print '######### - VALID BY DIALPAD - ################'
for l in dialpad_cases:
try:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x
except Exception as e:
print '%15s' % l, '%25s' % e
# Invalid Strings
invalid_strings = ['+4916190899790', # https://switchcomm.atlassian.net/browse/TEL-8824 Not Fixed
'+2022577744',
'+205739250',
]
print '######### - INVALID NUMBERS - ################'
for l in invalid_strings:
x = phonenumbers.parse(l, None)
print '%15s' % l, '%10s' % phonenumbers.is_valid_number(x), '%25s' % x
# National Format match
national_format_match = {'+525547808256': '55 4780 8256'}
print '######### - NUMBER FORMAT VALIDITY - ################'
for l in national_format_match:
x = phonenumbers.parse(l, None)
y = phonenumbers.format_number(x, phonenumbers.PhoneNumberFormat.NATIONAL)
if national_format_match[l] == y:
status = 'Success'
else:
status = 'Failed'
print (l), '-> %10s : %s' % (y, status)
# Number validity check
number_validity_check = {'1932621160': 'BR'}
print '######### - REGION NUMBER VALIDITY - ###############'
for l in number_validity_check:
region = number_validity_check[l]
x = phonenumbers.parse(l, region)
print '%15s' % l, '%10s -> Region : %5s' % (phonenumbers.is_valid_number(x), region)