def test_prep_value(self):
     '''
     Tests correct db storage value against different setting of
     PHONENUMBER_DB_FORMAT
     Required output format is set as string constant to guarantee
     consistent database storage values
     '''
     number = PhoneNumberField()
     old_format = getattr(settings, 'PHONENUMBER_DB_FORMAT', 'E164')
     for frmt in ['E164', 'RFC3966', 'INTERNATIONAL']:
         setattr(settings, 'PHONENUMBER_DB_FORMAT', frmt)
         self.assertEqual(
             number.get_prep_value(
                 to_python(self.storage_numbers[frmt][0])
             ),
             self.storage_numbers[frmt][1])
     setattr(settings, 'PHONENUMBER_DB_FORMAT', old_format)
 def test_does_not_fail_on_invalid_values(self):
     # testcase for
     # https://github.com/stefanfoulis/django-phonenumber-field/issues/11
     phone = to_python(42)
     self.assertEqual(phone, None)
Esempio n. 3
0
 def test_does_not_fail_on_invalid_values(self):
     # testcase for https://github.com/stefanfoulis/django-phonenumber-field/issues/11
     phone = to_python(42)
     self.assertEqual(phone, None)