def test__format_storage(self): # (npa, nxx, xxxx, ext, expect, label) tests = [ ('519', '291', '5554', '123', '5192915554123', 'all parts'), ('519', '291', '5554', '', '5192915554', 'no ext'), ('', '291', '5554', '123', '', 'no npa'), ('519', '', '5554', '123', '', 'no nxx'), ('519', '291', '', '123', '', 'no xxxx'), ('', '', '', '', '', 'no parts'), ] for t in tests: phone = PhoneNumber('') phone.npa = t[0] phone.nxx = t[1] phone.xxxx = t[2] phone.ext = t[3] self.assertEqual(phone.format_storage(), t[4]) # Handle non-typical phone number value = 'Not Available' phone = PhoneNumber(value) self.assertEqual(phone.format_storage(), value) phone = PhoneNumber(' ' + value + ' ') self.assertEqual(phone.format_storage(), value)
def test__extension(self): phone = PhoneNumber('') self.assertEqual(phone.extension(), '') phone.ext = '123' self.assertEqual(phone.extension(), '123')
def test__area_code(self): phone = PhoneNumber('') self.assertEqual(phone.area_code(), '') phone.npa = '519' self.assertEqual(phone.area_code(), '519')
def test__exchange(self): phone = PhoneNumber('') self.assertEqual(phone.exchange(), '') phone.nxx = '291' self.assertEqual(phone.exchange(), '291')
def test__station(self): phone = PhoneNumber('') self.assertEqual(phone.station(), '') phone.xxxx = '5554' self.assertEqual(phone.station(), '5554')