Add PhoneNumber python_type, refs #248
This commit is contained in:
@@ -153,9 +153,7 @@ class PhoneNumberType(types.TypeDecorator, ScalarCoercible):
|
||||
"""
|
||||
STORE_FORMAT = 'e164'
|
||||
impl = types.Unicode(20)
|
||||
|
||||
def python_type(self, text):
|
||||
return self._coerce(text)
|
||||
python_type = PhoneNumber
|
||||
|
||||
def __init__(self, region='US', max_length=20, *args, **kwargs):
|
||||
# Bail if phonenumbers is not found.
|
||||
|
@@ -150,6 +150,9 @@ class TestPhoneNumberType(object):
|
||||
session.refresh(user)
|
||||
assert user.phone_number is None
|
||||
|
||||
def test_uses_phonenumber_class_as_python_type(self):
|
||||
assert PhoneNumberType().python_type is PhoneNumber
|
||||
|
||||
@pytest.mark.usefixtures('user')
|
||||
def test_phone_number_is_none(self, session, User):
|
||||
phone_number = None
|
||||
|
Reference in New Issue
Block a user