diff options
Diffstat (limited to 'examples/flask_alchemy/test_demoapp.py')
-rw-r--r-- | examples/flask_alchemy/test_demoapp.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/flask_alchemy/test_demoapp.py b/examples/flask_alchemy/test_demoapp.py new file mode 100644 index 0000000..b485a92 --- /dev/null +++ b/examples/flask_alchemy/test_demoapp.py @@ -0,0 +1,35 @@ +import os +import unittest +import tempfile + +import demoapp +import demoapp_factories + +class DemoAppTestCase(unittest.TestCase): + + def setUp(self): + demoapp.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' + demoapp.app.config['TESTING'] = True + self.app = demoapp.app.test_client() + self.db = demoapp.db + self.db.create_all() + + def tearDown(self): + self.db.drop_all() + + def test_user_factory(self): + user = demoapp_factories.UserFactory() + self.db.session.commit() + self.assertIsNotNone(user.id) + self.assertEqual(1, len(demoapp.User.query.all())) + + def test_userlog_factory(self): + userlog = demoapp_factories.UserLogFactory() + self.db.session.commit() + self.assertIsNotNone(userlog.id) + self.assertIsNotNone(userlog.user.id) + self.assertEqual(1, len(demoapp.User.query.all())) + self.assertEqual(1, len(demoapp.UserLog.query.all())) + +if __name__ == '__main__': + unittest.main() |