allow field choices to be specified as a set
This commit is contained in:
@@ -3205,8 +3205,22 @@ class FieldTest(unittest.TestCase):
|
||||
shirt.size = "XS"
|
||||
self.assertRaises(ValidationError, shirt.validate)
|
||||
|
||||
def test_choices_as_set(self):
|
||||
"""Ensure that sets can be used as field choices"""
|
||||
class Shirt(Document):
|
||||
size = StringField(choices={'S', 'M', 'L', 'XL', 'XXL'})
|
||||
|
||||
Shirt.drop_collection()
|
||||
|
||||
shirt = Shirt()
|
||||
shirt.validate()
|
||||
|
||||
shirt.size = "S"
|
||||
shirt.validate()
|
||||
|
||||
shirt.size = "XS"
|
||||
self.assertRaises(ValidationError, shirt.validate)
|
||||
|
||||
def test_choices_validation_documents(self):
|
||||
"""
|
||||
Ensure fields with document choices validate given a valid choice.
|
||||
|
||||
Reference in New Issue
Block a user