MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / test_long_validation

Method test_long_validation

tests/fields/test_long_field.py:42–57  ·  view source on GitHub ↗

Ensure that invalid values cannot be assigned to long fields.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 2

TestDocumentClass · 0.70
validateMethod · 0.45

Tested by

no test coverage detected