예제 #1
0
 def test_none_user_can_view_public_task(self):
     # given
     task = Task('task', is_public=True)
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, None)
     # then
     self.assertTrue(result)
예제 #2
0
 def test_none_user_cannot_view_private_task(self):
     # given
     task = Task('task')
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, None)
     # then
     self.assertFalse(result)
예제 #3
0
 def test_anon_user_cannot_view_private_task(self):
     # given
     task = Task('task')
     anon = AnonymousUserMixin()
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, anon)
     # then
     self.assertFalse(result)
예제 #4
0
 def test_guest_user_cannot_view_private_task(self):
     # given
     task = Task('task')
     guest = self.pl.get_guest_user()
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, guest)
     # then
     self.assertFalse(result)
예제 #5
0
 def test_anon_user_can_view_public_task(self):
     # given
     task = Task('task', is_public=True)
     anon = AnonymousUserMixin()
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, anon)
     # then
     self.assertTrue(result)
예제 #6
0
 def test_guest_user_can_view_public_task(self):
     # given
     task = Task('task', is_public=True)
     guest = self.pl.get_guest_user()
     self.pl.add(task)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, guest)
     # then
     self.assertTrue(result)
예제 #7
0
 def test_unauthorized_nonadmin_can_view_public_task(self):
     # given
     task = Task('task', is_public=True)
     user = User('*****@*****.**')
     self.pl.add(task)
     self.pl.add(user)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, user)
     # then
     self.assertTrue(result)
예제 #8
0
 def test_unauthorized_admin_can_view_private_task(self):
     # given
     task = Task('task')
     user = User('*****@*****.**', None, True)
     self.pl.add(task)
     self.pl.add(user)
     self.pl.commit()
     # when
     result = TaskUserOps.user_can_view_task(task, user)
     # then
     self.assertTrue(result)