'Ensure that capped collections work properly.'

def test_capped_collection(self):

    class Log(Document, ):
        date = DateTimeField(default=datetime.now)
        meta = {'max_documents': 10, 'max_size': 4096}
    Log.drop_collection()
    for _ in range(10):
        Log().save()
    self.assertEqual(Log.objects.count(), 10)
    Log().save()
    self.assertEqual(Log.objects.count(), 10)
    options = Log.objects._collection.options()
    self.assertEqual(options['capped'], True)
    self.assertEqual(options['max'], 10)
    self.assertEqual(options['size'], 4096)
    class Log(Document, ):
        date = DateTimeField(default=datetime.now)
        meta = {'max_documents': 11}
    with self.assertRaises(InvalidCollectionError):
        Log.objects
