Ensure that list field handles validation if provided a strict field type.
(self)
| 1007 | assert repr(foo.bars) == "[<Bar: Bar object>]" |
| 1008 | |
| 1009 | def test_list_field_strict(self): |
| 1010 | """Ensure that list field handles validation if provided |
| 1011 | a strict field type. |
| 1012 | """ |
| 1013 | |
| 1014 | class Simple(Document): |
| 1015 | mapping = ListField(field=IntField()) |
| 1016 | |
| 1017 | Simple.drop_collection() |
| 1018 | |
| 1019 | e = Simple() |
| 1020 | e.mapping = [1] |
| 1021 | e.save() |
| 1022 | |
| 1023 | # try creating an invalid mapping |
| 1024 | with pytest.raises(ValidationError): |
| 1025 | e.mapping = ["abc"] |
| 1026 | e.save() |
| 1027 | |
| 1028 | def test_list_field_max_length(self): |
| 1029 | """Ensure ListField's max_length is respected.""" |
nothing calls this directly
no test coverage detected