From 37bbd30cd881736641ca41708a21f666bbe9e89b Mon Sep 17 00:00:00 2001 From: Wire Date: Mon, 13 Jul 2020 00:12:08 +0200 Subject: [PATCH] re-organization --- microblog.py | 7 ------- tests.py | 45 --------------------------------------------- 2 files changed, 52 deletions(-) delete mode 100644 microblog.py delete mode 100644 tests.py diff --git a/microblog.py b/microblog.py deleted file mode 100644 index 3c32c5e..0000000 --- a/microblog.py +++ /dev/null @@ -1,7 +0,0 @@ -from app import app, db -from app.models import User, Post - - -@app.shell_context_processor -def make_shell_context(): - return {'db': db, 'User': User, 'Post': Post} diff --git a/tests.py b/tests.py deleted file mode 100644 index 76ec499..0000000 --- a/tests.py +++ /dev/null @@ -1,45 +0,0 @@ -from datetime import datetime, timedelta -import unittest -from app import app, db -from app.models import User, Post - -class UserModelCase(unittest.TestCase): - def setUp(self): - app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' - db.create_all() - - def tearDown(self): - db.session.remove() - db.drop_all() - - def test_password_hashing(self): - u = User(username='susan') - u.set_password('cat') - self.assertFalse(u.check_password('dog')) - self.assertTrue(u.check_password('cat')) - - def test_follow(self): - u1 = User(username='john', email='john@example.com') - u2 = User(username='Snowden', realUser=False) - db.session.add(u1) - db.session.add(u2) - db.session.commit() - self.assertEqual(u1.followed.all(), []) - self.assertEqual(u1.followers.all(), []) - - u1.follow(u2) - db.session.commit() - self.assertTrue(u1.is_following(u2)) - self.assertEqual(u1.followed.count(), 1) - self.assertEqual(u1.followed.first().username, 'Snowden') - self.assertEqual(u2.followers.count(), 1) - self.assertEqual(u2.followers.first().username, 'john') - - u1.unfollow(u2) - db.session.commit() - self.assertFalse(u1.is_following(u2)) - self.assertEqual(u1.followed.count(), 0) - self.assertEqual(u2.followers.count(), 0) - -if __name__ == '__main__': - unittest.main(verbosity=2) \ No newline at end of file