Commit f1f0d8e8 authored by Andreasjj's avatar Andreasjj
Browse files

added the last tests

parent db7d9837
Pipeline #112967 passed with stages
in 1 minute and 54 seconds
......@@ -92,10 +92,32 @@ class PermissionTestCase(TestCase):
def test_IsCoachAndVisibleToCoach(self):
# Permission class to test
permission = IsCoachAndVisibleToCoach()
#
owner = MagicMock(coach = self.requester)
obj = MagicMock(owner = owner)
new_coach = MagicMock()
not_requester_owner = MagicMock(coach = new_coach)
not_requester_obj = MagicMock(owner = not_requester_owner)
#
self.assertTrue(permission.has_object_permission(self.request, self.view, obj))
self.assertFalse(permission.has_object_permission(self.request, self.view, not_requester_obj))
def test_IsCoachOfWorkoutAndVisibleToCoach(self):
# Permission class to test
permission = IsCoachOfWorkoutAndVisibleToCoach()
#
owner = MagicMock(coach = self.requester)
workout = MagicMock(owner = owner)
obj = MagicMock(workout = workout)
new_coach = MagicMock()
not_requester_owner = MagicMock(coach = new_coach)
not_requester_workout = MagicMock(owner = not_requester_owner)
not_requester_obj = MagicMock(workout = not_requester_workout)
#
self.assertTrue(permission.has_object_permission(self.request, self.view, obj))
self.assertFalse(permission.has_object_permission(self.request, self.view, not_requester_obj))
def test_IsPublic(self):
# Permission class to test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment