Ensure that invalid values cannot be assigned to long fields.
(self)
| 40 | assert isinstance(doc.some_long, int) |
| 41 | |
| 42 | def test_long_validation(self): |
| 43 | """Ensure that invalid values cannot be assigned to long fields.""" |
| 44 | |
| 45 | class TestDocument(Document): |
| 46 | value = LongField(min_value=0, max_value=110) |
| 47 | |
| 48 | TestDocument(value=50).validate() |
| 49 | |
| 50 | with pytest.raises(ValidationError): |
| 51 | TestDocument(value=-1).validate() |
| 52 | |
| 53 | with pytest.raises(ValidationError): |
| 54 | TestDocument(value=120).validate() |
| 55 | |
| 56 | with pytest.raises(ValidationError): |
| 57 | TestDocument(value="ten").validate() |
| 58 | |
| 59 | def test_long_ne_operator(self): |
| 60 | class TestDocument(Document): |
nothing calls this directly
no test coverage detected