MongoEngine/flask-mongoengine — pull request #80 by rogemita (2014-02-18 22:39:30+00:00)
Title: Testing applications using a test database

Testing applications
====================

If your **MONGODB_SETTINGS** is {"DB": "my_tumble_log"}, your tests will go to run using **test_my_tumble_log** database

basic_app.py

from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config.from_pyfile('the-config.cfg')
db = MongoEngine(app)

test_basic_app.py

from basic_app import db
from flask.ext.mongoengine.test import TestCase_factory

TestCase = TestCase_factory(db)

class BasicAppTestCase(TestCase):

def test_simple_test(self):
..