Merge branch 'master' of https://github.com/MongoEngine/mongoengine
This commit is contained in:
commit
eacb614750
@ -153,7 +153,7 @@ class EmailField(StringField):
|
|||||||
EMAIL_REGEX = re.compile(
|
EMAIL_REGEX = re.compile(
|
||||||
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
|
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
|
||||||
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
|
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
|
||||||
r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,253}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE # domain
|
r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,253}[A-Z0-9])?\.)+[A-Z]{2,6}$', re.IGNORECASE # domain
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
|
@ -2499,6 +2499,9 @@ class FieldTest(unittest.TestCase):
|
|||||||
user = User(email="ross@example.com")
|
user = User(email="ross@example.com")
|
||||||
self.assertTrue(user.validate() is None)
|
self.assertTrue(user.validate() is None)
|
||||||
|
|
||||||
|
user = User(email="ross@example.co.uk")
|
||||||
|
self.assertTrue(user.validate() is None)
|
||||||
|
|
||||||
user = User(email=("Kofq@rhom0e4klgauOhpbpNdogawnyIKvQS0wk2mjqrgGQ5S"
|
user = User(email=("Kofq@rhom0e4klgauOhpbpNdogawnyIKvQS0wk2mjqrgGQ5S"
|
||||||
"ucictfqpdkK9iS1zeFw8sg7s7cwAF7suIfUfeyueLpfosjn3"
|
"ucictfqpdkK9iS1zeFw8sg7s7cwAF7suIfUfeyueLpfosjn3"
|
||||||
"aJIazqqWkm7.net"))
|
"aJIazqqWkm7.net"))
|
||||||
@ -2507,6 +2510,9 @@ class FieldTest(unittest.TestCase):
|
|||||||
user = User(email='me@localhost')
|
user = User(email='me@localhost')
|
||||||
self.assertRaises(ValidationError, user.validate)
|
self.assertRaises(ValidationError, user.validate)
|
||||||
|
|
||||||
|
user = User(email="ross@example.com.")
|
||||||
|
self.assertRaises(ValidationError, user.validate)
|
||||||
|
|
||||||
def test_email_field_honors_regex(self):
|
def test_email_field_honors_regex(self):
|
||||||
class User(Document):
|
class User(Document):
|
||||||
email = EmailField(regex=r'\w+@example.com')
|
email = EmailField(regex=r'\w+@example.com')
|
||||||
@ -2594,13 +2600,13 @@ class FieldTest(unittest.TestCase):
|
|||||||
def test_invalid_dict_value(self):
|
def test_invalid_dict_value(self):
|
||||||
class DictFieldTest(Document):
|
class DictFieldTest(Document):
|
||||||
dictionary = DictField(required=True)
|
dictionary = DictField(required=True)
|
||||||
|
|
||||||
DictFieldTest.drop_collection()
|
DictFieldTest.drop_collection()
|
||||||
|
|
||||||
test = DictFieldTest(dictionary=None)
|
test = DictFieldTest(dictionary=None)
|
||||||
test.dictionary # Just access to test getter
|
test.dictionary # Just access to test getter
|
||||||
self.assertRaises(ValidationError, test.validate)
|
self.assertRaises(ValidationError, test.validate)
|
||||||
|
|
||||||
test = DictFieldTest(dictionary=False)
|
test = DictFieldTest(dictionary=False)
|
||||||
test.dictionary # Just access to test getter
|
test.dictionary # Just access to test getter
|
||||||
self.assertRaises(ValidationError, test.validate)
|
self.assertRaises(ValidationError, test.validate)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user