3 ms·
Could you put an example on pastebin or somewhere? I would really appreciate this.
by viandante 15y ago
Could you put an example on pastebin or somewhere? I would really appreciate this.
- johnpaulett 15y agoAlong the lines of http://flask.pocoo.org/docs/patterns/mongokit/ http://flask.pocoo.org/docs/patterns/mongokit/, I have a MONGODB_DATABASE setting, which is set to my normal database name. Then access the database via the connections' dictionary syntax, instead of attribute syntax (I have a helper method to make this prettier): 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')
- viandante 15y agoThanks a lot man. This was really useful, I am on my first steps with unittest.