Sha256: de1d4731ab3ceb242a70d51667dc7863bbae3ce312ff94a574a983fe3dc5eeab

Contents?: true

Size: 1.2 KB

Versions: 131

Compression:

Stored size: 1.2 KB

Contents

import unittest

from phone_number import Phone


class PhoneTest(unittest.TestCase):
    def test_cleans_number(self):
        number = Phone("(123) 456-7890").number
        self.assertEqual(number, "1234567890")

    def test_cleans_number_with_dots(self):
        number = Phone("123.456.7890").number
        self.assertEqual(number, "1234567890")

    def test_valid_when_11_digits_and_first_is_1(self):
        number = Phone("11234567890").number
        self.assertEqual(number, "1234567890")

    def test_invalid_when_11_digits(self):
        number = Phone("21234567890").number
        self.assertEqual(number, "0000000000")

    def test_invalid_when_9_digits(self):
        number = Phone("123456789").number
        self.assertEqual(number, "0000000000")

    def test_area_code(self):
        number = Phone("1234567890")
        self.assertEqual(number.area_code(), "123")

    def test_pretty_print(self):
        number = Phone("1234567890")
        self.assertEqual(number.pretty(), "(123) 456-7890")

    def test_pretty_print_with_full_us_phone_number(self):
        number = Phone("11234567890")
        self.assertEqual(number.pretty(), "(123) 456-7890")


if __name__ == '__main__':
    unittest.main()

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
trackler-2.2.1.40 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.39 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.38 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.37 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.36 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.35 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.34 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.33 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.32 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.31 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.30 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.29 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.28 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.27 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.26 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.25 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.24 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.23 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.22 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.2.1.21 tracks/python/exercises/phone-number/phone_number_test.py