by viandante · 15y ago · 0 comments
For testing a MongoDB database, I wrote a simple unittest.TestCase subclass that in the setUp and tearDown, creates and then deletes a test database.
connection[app.config['MONGODB_DATABASE']].mycollection.find_one()
The unittest code just modifies the setting: import unittest
def setUp(self):
myapp.app.config['MONGODB_DATABASE'] = 'test'
self.app = myapp.app.test_client()
def tearDown(self):
# can clean up here, e.g.
connection.test.drop_collection('mycollection')