def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles() self.client = self.app.test_client()
def index(): Role.insert_roles() role = Role.query.filter_by(name='User').first() user = User.query.filter_by(role=role).all() for user1 in user: print user1.username return render_template('main/index.html')
def test_anonymous_user(self): Role.insert_roles() u = AnonymousUser() self.assertFalse(u.can(Permission.COMMENT)) self.assertFalse(u.can(Permission.WRITE)) self.assertFalse(u.can(Permission.FOLLOW)) self.assertFalse(u.can(Permission.ADMIN)) self.assertFalse(u.can(Permission.MODERATE))
def test_user_role(self): Role.insert_roles() u = User(name='ose', password='******', email='*****@*****.**') self.assertTrue(u.can(Permission.COMMENT)) self.assertTrue(u.can(Permission.WRITE)) self.assertTrue(u.can(Permission.FOLLOW)) self.assertFalse(u.can(Permission.ADMIN)) self.assertFalse(u.can(Permission.MODERATE))
def test_admin(self): Role.insert_roles() u = User(name='ose', password='******', email='*****@*****.**', id=1) self.assertTrue(u.can(Permission.COMMENT)) self.assertTrue(u.can(Permission.WRITE)) self.assertTrue(u.can(Permission.FOLLOW)) self.assertTrue(u.can(Permission.ADMIN)) self.assertTrue(u.can(Permission.MODERATE))
def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.drop_all() db.create_all() db.session.commit() Role.insert_roles() User.insert_root_admin() self.client = self.app.test_client()
def deploy(): """Run deployment tasks and prepare necessary data""" upgrade() Role.insert_roles() User.insert_root_admin()
def deploy(): """Run deployment tasks.""" upgrade() Role.insert_roles() User.insert_root_admin()