fix complex datetime field invalid string set
This commit is contained in:
		| @@ -4,6 +4,8 @@ import itertools | ||||
| import math | ||||
| import re | ||||
|  | ||||
| import pytest | ||||
|  | ||||
| from mongoengine import * | ||||
|  | ||||
| from tests.utils import MongoDBTestCase | ||||
| @@ -191,3 +193,18 @@ class ComplexDateTimeFieldTest(MongoDBTestCase): | ||||
|  | ||||
|         fetched_log = Log.objects.with_id(log.id) | ||||
|         assert fetched_log.timestamp >= NOW | ||||
|  | ||||
|     def test_setting_bad_value_does_not_raise_unless_validate_is_called(self): | ||||
|         # test regression of #2253 | ||||
|  | ||||
|         class Log(Document): | ||||
|             timestamp = ComplexDateTimeField() | ||||
|  | ||||
|         Log.drop_collection() | ||||
|  | ||||
|         log = Log(timestamp="garbage") | ||||
|         with pytest.raises(ValidationError): | ||||
|             log.validate() | ||||
|  | ||||
|         with pytest.raises(ValidationError): | ||||
|             log.save() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user