'Ensure that every field can handle null values from the
database.'

def test_not_required_handles_none_from_database(self):

    class HandleNoneFields(Document, ):
        str_fld = StringField(required=True)
        int_fld = IntField(required=True)
        flt_fld = FloatField(required=True)
        comp_dt_fld = ComplexDateTimeField(required=True)
    HandleNoneFields.drop_collection()
    doc = HandleNoneFields()
    doc.str_fld = u'spam    ham    egg'
    doc.int_fld = 42
    doc.flt_fld = 4.2
    doc.com_dt_fld = datetime.datetime.utcnow()
    doc.save()
    obj = HandleNoneFields._get_collection().update({'_id': doc.id}, {'$unset': {'str_fld': 1, 'int_fld': 1, 'flt_fld': 1, 'comp_dt_fld': 1}})
    ret = HandleNoneFields.objects.first()
    self.assertEqual(ret.str_fld, None)
    self.assertEqual(ret.int_fld, None)
    self.assertEqual(ret.flt_fld, None)
    self.assertTrue(isinstance(ret.comp_dt_fld, datetime.datetime))
    self.assertRaises(ValidationError, ret.validate)
