Exemplo n.º 1
0
 def test_bone(self):
     self.create_admin()
     self.post("test", "testdesc", 100, "Male", "husky")
     with APP.app_context():
         id = DB.session.query(Post).first().id
         likedbefore = DB.session.query(User).first().has_liked(id)
     response = self.bone(id, 'like')
     with APP.app_context():
         likedafter = DB.session.query(User).first().has_liked(id)
     self.assertNotEqual(likedbefore, likedafter)
Exemplo n.º 2
0
    def test_comments(self):
        self.create_admin()
        self.post("test", "testdesc", 100, "Male", "husky")
        with APP.app_context():
            id = DB.session.query(Post).first().id
        response = self.comment(id, "comentariutest")

        n = 0
        with APP.app_context():
            n = DB.session.query(Comment).count()
        self.assertEqual(1, n)
Exemplo n.º 3
0
    def test_delete_post(self):
        self.create_admin()
        self.post("test", "testdesc", 100, "Male", "husky")
        with APP.app_context():
            id = DB.session.query(Post).first().id
            countbefore = DB.session.query(Post).count()

        response = self.APP.post(('/delete_post?id=%d' % id),
                                 follow_redirects=True)
        with APP.app_context():
            countafter = DB.session.query(Post).count()
        self.assertNotEqual(countbefore, countafter)
Exemplo n.º 4
0
 def create_admin(self):
     response = self.register('*****@*****.**', 'admin123', 'admin')
     with APP.app_context():
         DB.session.query(User).first().rank = 1
         DB.session.commit()
     response = self.login('admin', 'admin123')
     self.assertEqual(response.status_code, 200)
Exemplo n.º 5
0
 def test_valid_posting(self):
     self.create_admin()
     response = self.post("test", "testdesc", 100, "Male", "husky")
     response = self.post("test2", "testdesc", 100, "Male", "husky")
     n = 0
     with APP.app_context():
         n = DB.session.query(Post).count()
     self.assertEqual(2, n)
Exemplo n.º 6
0
 def setUp(self):
     with APP.app_context():
         APP.config['TESTING'] = True
         APP.config['WTF_CSRF_ENABLED'] = False
         APP.config['DEBUG'] = False
         APP.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
         self.APP = APP.test_client()
         DB.init_app(APP)
         DB.drop_all()
         DB.create_all()
     self.assertEqual(APP.debug, False)
Exemplo n.º 7
0
 def test_profile(self):
     self.create_admin()
     self.APP.post('/profile',
                   data=dict(last_name="gigel",
                             first_name="adminul",
                             phone="0722222222"),
                   follow_redirects=True)
     with APP.app_context():
         user = DB.session.query(User).first()
     self.assertEqual(user.last_name, "gigel")
     self.assertEqual(user.first_name, "adminul")
     self.assertEqual(user.phone, "0722222222")
Exemplo n.º 8
0
def app():
    """Yield your app with its context set up and ready"""
    with APP.app_context():
        yield APP