示例#1
0
 def should_use_choices_values(self):
     doc = MongoFuel.create_one(FieldsWithChoicesDocument)
     for field_name, field_obj in doc._fields.items():
         if isinstance(field_obj, ObjectIdField):
             continue
         value = getattr(doc, field_name)
         self.assertIn(value, field_obj.choices)
示例#2
0
 def should_not_create_fields_that_are_not_required(self):
     doc = MongoFuel.create_one(NotRequiredFieldsDocument)
     for field_name, field_obj in doc._fields.items():
         if isinstance(field_obj, ObjectIdField):
             continue
         value = getattr(doc, field_name)
         self.assertFalse(value)
示例#3
0
 def should_not_overrides_default_values(self):
     doc = MongoFuel.create_one(DefaultFieldsDocument)
     for field_name, field_obj in doc._fields.items():
         if isinstance(field_obj, ObjectIdField):
             continue
         value = getattr(doc, field_name)
         default = field_obj.default
         self.assertEqual(value, default)
示例#4
0
    def test_classmethod_to_create_documents(self):
        self.assertEqual(IntegerFieldDocument.objects.count(), 0)

        document = MongoFuel.create_one(IntegerFieldDocument)

        self.assertEqual(IntegerFieldDocument.objects.count(), 1)