From 8ff63f4538bb5ddc7cec134704d1e83e5ff0af1f Mon Sep 17 00:00:00 2001 From: Surbhi Sharma Date: Wed, 8 Sep 2021 18:14:31 +0530 Subject: [PATCH] fix : tests.py --- tests.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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)