Merge pull request #2514 from bagerard/enum_field_update
improvement to recent updates
This commit is contained in:
commit
5209547a89
@ -7,12 +7,12 @@ Changelog
|
||||
Development
|
||||
===========
|
||||
- (Fill this out as you fix issues and develop your features).
|
||||
- EnumField improvements: now `choices` limits the values of an enum to allow
|
||||
|
||||
Changes in 0.23.1
|
||||
===========
|
||||
- Bug fix: ignore LazyReferenceFields when clearing _changed_fields #2484
|
||||
- Improve connection doc #2481
|
||||
- EnumField improvements: now `choices` limits the values of an enum to allow
|
||||
|
||||
Changes in 0.23.0
|
||||
=================
|
||||
|
@ -81,7 +81,17 @@ class TestStringEnumField(MongoDBTestCase):
|
||||
|
||||
def test_partial_choices(self):
|
||||
partial = [Status.DONE]
|
||||
assert EnumField(Status, choices=partial).choices == partial
|
||||
enum_field = EnumField(Status, choices=partial)
|
||||
assert enum_field.choices == partial
|
||||
|
||||
class FancyDoc(Document):
|
||||
z = enum_field
|
||||
|
||||
FancyDoc(z=Status.DONE).validate()
|
||||
with pytest.raises(
|
||||
ValidationError, match=r"Value must be one of .*Status.DONE"
|
||||
):
|
||||
FancyDoc(z=Status.NEW).validate()
|
||||
|
||||
def test_wrong_choices(self):
|
||||
with pytest.raises(ValueError, match="Invalid choices"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user