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)
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)
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)
def test_classmethod_to_create_documents(self): self.assertEqual(IntegerFieldDocument.objects.count(), 0) document = MongoFuel.create_one(IntegerFieldDocument) self.assertEqual(IntegerFieldDocument.objects.count(), 1)