示例#1
0
    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))
示例#2
0
    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))
示例#3
0
    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)
示例#4
0
    def test_create_request__unauth(self):
        """Should refuse"""
        request = factory.post('/')
        request.user = auth_models.AnonymousUser()

        self.assertFalse(ObjectOwnership().has_permission(request, None))
示例#5
0
    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)