コード例 #1
0
 def test_group_member_role(self):
     """ A group member is allowed to create tasks etc. in groups,'
     but not moderate them nor administer the site """
     r = Role.query.filter_by(role_name='Group role').first()
     u = User(email='*****@*****.**', password='******', role=r)
     self.assertTrue(u.can(Permission.CREATE_TASKS))
     self.assertTrue(u.can(Permission.CREATE_GROUPS))
     self.assertTrue(u.can(Permission.CREATE_GROUP_TASKS))
     self.assertFalse(u.can(Permission.MODERATE_GROUP))
     self.assertFalse(u.can(Permission.ADMIN))
コード例 #2
0
 def test_group_moderator_role(self):
     """" A group moderator is allowed to moderate groups, but not
     administer the site """
     r = Role.query.filter_by(role_name='Moderator').first()
     u = User(email='*****@*****.**', password='******', role=r)
     self.assertFalse(u.can(Permission.ADMIN))
     self.assertTrue(u.can(Permission.CREATE_GROUPS))
     self.assertTrue(u.can(Permission.CREATE_GROUP_TASKS))
     self.assertTrue(u.can(Permission.CREATE_TASKS))
     self.assertTrue(u.can(Permission.MODERATE_GROUP))
コード例 #3
0
 def test_user_role(self):
     """ Tests that a basic user can only create tasks and create groups """
     u = User(username='******',
              email='*****@*****.**',
              password='******')
     self.assertTrue(u.can(Permission.CREATE_TASKS))
     self.assertTrue(u.can(Permission.CREATE_GROUPS))
     self.assertFalse(u.can(Permission.CREATE_GROUP_TASKS))
     self.assertFalse(u.can(Permission.MODERATE_GROUP))
     self.assertFalse(u.can(Permission.ADMIN))
コード例 #4
0
 def test_administrator_role(self):
     """ Administrator should be allowed to do all tasks """
     r = Role.query.filter_by(role_name='Administrator').first()
     u = User(email='*****@*****.**',
              password='******',
              role=r)
     self.assertTrue(u.can(Permission.ADMIN))
     self.assertTrue(u.can(Permission.CREATE_GROUPS))
     self.assertTrue(u.can(Permission.CREATE_GROUP_TASKS))
     self.assertTrue(u.can(Permission.CREATE_TASKS))
     self.assertTrue(u.can(Permission.MODERATE_GROUP))
コード例 #5
0
 def test_roles_and_permissions(self):
     u = User(email='*****@*****.**', password='******')
     self.assertTrue(u.can(Permission.WRITE_ARTICLES))
     self.assertFalse(u.can(Permission.MODERATE_COMMENTS))