diff --git a/tests.py b/tests.py index 3dc0546..e6b5b5e 100644 --- a/tests.py +++ b/tests.py @@ -1,21 +1,28 @@ from datetime import datetime, timedelta import unittest -from app import app, db +from app import create_app, db from app.models import User, Post +from config import Config + class TestConfig(Config): TESTING = True SQLALCHEMY_DATABASE_URI = 'sqlite://' + class UserModelCase(unittest.TestCase): + def setUp(self): - app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' + self.app = create_app(TestConfig) + self.app_context = self.app.app_context() + self.app_context.push() db.create_all() def tearDown(self): db.session.remove() db.drop_all() - + self.app_context.pop() + def test_password_hashing(self): u = User(username='susan') u.set_password('cat') @@ -89,5 +96,6 @@ def test_follow_posts(self): self.assertEqual(f3, [p3, p4]) self.assertEqual(f4, [p4]) + if __name__ == '__main__': unittest.main(verbosity=2)