def test_edit_request__not_owner(self): """Should refuse""" request = factory.patch('/80001') request.user = User.objects.get(pk=70002) # not owner of test event view = DummyObjectView(Event.objects.get(pk=80001)) self.assertFalse(ObjectOwnership().has_permission(request, view))
def test_edit_request__unauth(self): """Should refuse""" request = factory.patch('/80001') request.user = auth_models.AnonymousUser() view = DummyObjectView(Event.objects.get(pk=80001)) self.assertFalse(ObjectOwnership().has_permission(request, view))
def test_edit_request(self): """Should permit""" request = factory.patch('/80001') request.user = User.objects.get(pk=70001) # test user view = DummyObjectView(Event.objects.get(pk=80001)) assert ObjectOwnership().has_permission(request, view)
def test_create_request__unauth(self): """Should refuse""" request = factory.post('/') request.user = auth_models.AnonymousUser() self.assertFalse(ObjectOwnership().has_permission(request, None))
def test_create_request(self): """Should permit""" request = factory.post('/') request.user = User.objects.get(pk=70001) # test user assert ObjectOwnership().has_permission(request, None)