Exemple #1
0
 def test_valid(self):
     """validators.val_phone_number: Given a value, if the 
     value is a valid North American Numbering Plan phone 
     number, the function should return it.
     """
     expected = '309-555-5555'
     actual = v.val_phone_number(Descr(), expected)
     self.assertEqual(expected, actual)
Exemple #2
0
 def test_invalid(self):
     """validators.val_phone_number: Given a value, if the 
     value is not a valid North American Numbering Plan phone 
     number, the function should raise a ValueError exception.
     """
     expected = ValueError
     value = 'spam'
     with self.assertRaises(expected):
         _ = v.val_phone_number(Descr(), value)
Exemple #3
0
 def test_normalStr(self):
     """validators.val_phone_number: Given a value, if the 
     value is not a string, the function should coerce it 
     to a string.
     """
     expected = '309-555-5555'
     value = 3095555555
     actual = v.val_phone_number(Descr(), value)
     self.assertEqual(expected, actual)
Exemple #4
0
 def test_normalNoDelim(self):
     """validators.val_phone_number: Given a value, if the 
     value is not hyphen delimited, the function should add 
     the hyphen delimiters and return the value.
     """
     expected = '309-555-5555'
     value = '3095555555'
     actual = v.val_phone_number(Descr(), value)
     self.assertEqual(expected, actual)
Exemple #5
0
 def test_normalizeParens(self):
     """validators.val_phone_number: Given a value, if the 
     value contains an area code delimited by parentheses, 
     replace the delimiters with a hyphen.
     """
     expected = '309-555-5555'
     value = '(309)555-5555'
     actual = v.val_phone_number(Descr(), value)
     self.assertEqual(expected, actual)