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