コード例 #1
0
    def test_deny_cancel_other_affiliation_request(self):
        """
        users should never be allowed to cancel other user's affiliation requests
        """

        request = self.factory.post("/affiliate-to-org", data={"org": "AFFILORG"})
        request.user = self.user_b
        request._dont_enforce_csrf_checks = True
        response = pdbviews.view_affiliate_to_org(request)

        assert response.status_code == 200

        affiliation_request = self.user_b.pending_affiliation_requests.first()

        assert affiliation_request

        request = self.factory.post(
            f"/cancel-affiliation-request/{affiliation_request.id}/"
        )
        request.user = self.user_a
        request._dont_enforce_csrf_checks = True
        response = pdbviews.cancel_affiliation_request(request, affiliation_request.id)

        assert response.status_code == 404
        assert self.user_b.pending_affiliation_requests.count() == 1
コード例 #2
0
    def test_cancel_affiliation_request(self):
        """
        tests user canceling a pending affiliation request
        """

        request = self.factory.post("/affiliate-to-org", data={"org": "AFFILORG"})
        request.user = self.user_b
        request._dont_enforce_csrf_checks = True
        response = pdbviews.view_affiliate_to_org(request)

        assert response.status_code == 200

        affiliation_request = self.user_b.pending_affiliation_requests.first()

        assert affiliation_request

        request = self.factory.post(
            f"/cancel-affiliation-request/{affiliation_request.id}/"
        )
        request.user = self.user_b
        request._dont_enforce_csrf_checks = True
        response = pdbviews.cancel_affiliation_request(request, affiliation_request.id)

        assert response.status_code == 302
        assert self.user_b.pending_affiliation_requests.count() == 0