Python mongoengine.fields.DateTimeField() Examples
The following are 2
code examples of mongoengine.fields.DateTimeField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mongoengine.fields
, or try the search function
.
Example #1
Source File: test_basic.py From django-rest-framework-mongoengine with MIT License | 5 votes |
def test_regular_fields(self): """ Model fields should map to their equivelent serializer fields. """ class TestSerializer(DocumentSerializer): class Meta: model = RegularModel fields = '__all__' regex_repr = "re.compile('^valid_regex')" expected = dedent(""" TestSerializer(): id = ObjectIdField(read_only=True) str_field = CharField(required=False) str_regex_field = RegexField(regex=%s, required=False) url_field = URLField(required=False) email_field = EmailField(required=False) int_field = IntegerField(required=False) long_field = IntegerField(required=False) float_field = FloatField(required=False) boolean_field = BooleanField(required=False) nullboolean_field = NullBooleanField(required=False) date_field = DateTimeField(required=False) complexdate_field = DateTimeField(required=False) uuid_field = UUIDField(required=False) id_field = ObjectIdField(required=False) decimal_field = DecimalField(decimal_places=2, max_digits=65536, required=False) custom_field = DocumentField(model_field=<tests.test_basic.CustomField: custom_field>, required=False) """ % regex_repr) assert repr(TestSerializer()) == expected
Example #2
Source File: test_basic.py From django-rest-framework-mongoengine with MIT License | 5 votes |
def test_meta_exclude(self): """ Serializer should respect Meta.exclude """ class TestSerializer(DocumentSerializer): class Meta: model = RegularModel exclude = ('decimal_field', 'custom_field') regex_repr = "re.compile('^valid_regex')" expected = dedent(""" TestSerializer(): id = ObjectIdField(read_only=True) str_field = CharField(required=False) str_regex_field = RegexField(regex=%s, required=False) url_field = URLField(required=False) email_field = EmailField(required=False) int_field = IntegerField(required=False) long_field = IntegerField(required=False) float_field = FloatField(required=False) boolean_field = BooleanField(required=False) nullboolean_field = NullBooleanField(required=False) date_field = DateTimeField(required=False) complexdate_field = DateTimeField(required=False) uuid_field = UUIDField(required=False) id_field = ObjectIdField(required=False) """ % regex_repr) assert repr(TestSerializer()) == expected