Add PhoneNumber python_type, refs #248

This commit is contained in:
Konsta Vesterinen
2016-10-20 09:55:19 +03:00
parent b1f84e5998
commit ec7e2fefec
2 changed files with 4 additions and 3 deletions

View File

@@ -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.

View File

@@ -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