improvement to recent updates
This commit is contained in:
parent
34245fe258
commit
ecb5dda281
@ -7,12 +7,12 @@ Changelog
|
|||||||
Development
|
Development
|
||||||
===========
|
===========
|
||||||
- (Fill this out as you fix issues and develop your features).
|
- (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
|
Changes in 0.23.1
|
||||||
===========
|
===========
|
||||||
- Bug fix: ignore LazyReferenceFields when clearing _changed_fields #2484
|
- Bug fix: ignore LazyReferenceFields when clearing _changed_fields #2484
|
||||||
- Improve connection doc #2481
|
- Improve connection doc #2481
|
||||||
- EnumField improvements: now `choices` limits the values of an enum to allow
|
|
||||||
|
|
||||||
Changes in 0.23.0
|
Changes in 0.23.0
|
||||||
=================
|
=================
|
||||||
|
@ -81,7 +81,17 @@ class TestStringEnumField(MongoDBTestCase):
|
|||||||
|
|
||||||
def test_partial_choices(self):
|
def test_partial_choices(self):
|
||||||
partial = [Status.DONE]
|
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):
|
def test_wrong_choices(self):
|
||||||
with pytest.raises(ValueError, match="Invalid choices"):
|
with pytest.raises(ValueError, match="Invalid choices"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user