Sha256: 4f8842167c0275d26d967623fa3ee4d30bec9af01ed84957d02c67f65715902c

Contents?: true

Size: 1.2 KB

Versions: 101

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("1234567890", number)

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

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

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

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

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

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

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


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

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
trackler-2.0.8.27 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.26 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.24 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.23 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.22 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.21 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.20 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.19 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.18 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.17 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.16 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.15 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.14 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.13 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.12 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.11 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.10 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.9 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.8 tracks/python/exercises/phone-number/phone_number_test.py
trackler-2.0.8.7 tracks/python/exercises/phone-number/phone_number_test.py