34 lines
874 B
Python
34 lines
874 B
Python
import unittest
|
|
import s2_a4_a
|
|
|
|
test_numbers = [
|
|
("+1 223-456-7890", "1-223-456-7890"),
|
|
("1-223-456-7890", "1-223-456-7890"),
|
|
("+1 223 456-7890", "1-223-456-7890"),
|
|
("(223) 456-7890", "1-223-456-7890"),
|
|
("1 223 456 7890", "1-223-456-7890"),
|
|
("223.456.7890", "1-223-456-7890"),
|
|
("1-989-111-2222", "1-989-111-2222"),
|
|
]
|
|
|
|
test_numbers_invalid = [
|
|
"",
|
|
"+49 012 345 6821",
|
|
"+49 6821",
|
|
"1-182-324-4324",
|
|
"1-082-324-4324",
|
|
"1-682-624-1324",
|
|
"1-682-624-0324",
|
|
"1-682-624-5924",
|
|
]
|
|
|
|
|
|
class NumbersTests(unittest.TestCase):
|
|
def test_numbers(self):
|
|
for number, expected in test_numbers:
|
|
self.assertEqual(expected, s2_a4_a.parse_number(number))
|
|
|
|
def test_numbers_fails(self):
|
|
for number in test_numbers_invalid:
|
|
self.assertRaises(ValueError, lambda: s2_a4_a.parse_number(number))
|