@@ -507,6 +507,21 @@ def test__parent__init__method_included_in_init_chain(self, db, mocker):
507507 field_init_spy .assert_called_once ()
508508 mixin_init_spy .assert_called_once ()
509509
510+ def test__form_field_class__is_email_field__even_if_size_given__and_validators_set (
511+ self , db
512+ ):
513+ field = db .EmailField (max_length = 3 , min_length = 1 )
514+
515+ assert field .wtf_field_class is mongo_fields .MongoEmailField
516+ validator = [
517+ val
518+ for val in field .wtf_field_options ["validators" ]
519+ if val .__class__ is wtf_validators_ .Length
520+ ][0 ]
521+ assert validator is not None
522+ assert validator .min == 1
523+ assert validator .max == 3
524+
510525
511526class TestEmbeddedDocumentField :
512527 """Custom test set for :class:`~flask_mongoengine.wtf.db_fields.EmbeddedDocumentField`"""
@@ -1007,6 +1022,21 @@ def test__parent__init__method_included_in_init_chain(self, db, mocker):
10071022 field_init_spy .assert_called_once ()
10081023 mixin_init_spy .assert_called_once ()
10091024
1025+ def test__form_field_class__is_url_field__even_if_size_given__and_validators_set (
1026+ self , db
1027+ ):
1028+ field = db .URLField (max_length = 3 , min_length = 1 )
1029+
1030+ assert field .wtf_field_class is mongo_fields .MongoURLField
1031+ validator = [
1032+ val
1033+ for val in field .wtf_field_options ["validators" ]
1034+ if val .__class__ is wtf_validators_ .Length
1035+ ][0 ]
1036+ assert validator is not None
1037+ assert validator .min == 1
1038+ assert validator .max == 3
1039+
10101040
10111041class TestUUIDField :
10121042 """Custom test set for :class:`~flask_mongoengine.wtf.db_fields.UUIDField`"""
0 commit comments