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.1.0.22 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.21 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.20 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.19 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.18 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.17 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.16 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.15 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.14 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.13 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.12 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.11 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.10 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.9 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.8 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.7 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.6 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.5 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.4 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.1.0.3 tracks/python/exercises/phone-number/phone_number_test.py