def test_protected_post(self):
        
        self.client.login(username="test1", password="password")
        
        # Get permission url
        view_url = reverse("test_view_update", kwargs={"obj_id": self.objs[0].id})
        other_perm_url = reverse(
            "permissions_url",
            kwargs=dict(
                perm_name="can_set_val",
                permittee_ct_id=ContentType.objects.get_for_model(User).id,
                permittee_id = self.u1.id,
                target_ct_id=ContentType.objects.get_for_model(PermissionTestClass).id,
                target_id=self.objs[0].id,
            )
        )
        
        # try to update: Disallowed
        response = self.client.post(
            view_url,
            {"val": 5})
        self.assertRedirects(response, other_perm_url)
        self.assertEqual(self.client.session['from_url'], view_url)
        
        # get permission
        response = self.client.post(other_perm_url)
        self.assertRedirects(response, view_url)
        
        # Try to update: Allowed
        response = self.client.post(
            view_url,
            {"val": 5})
        self.assertRedirects(response, view_url)
        
        obj = PermissionTestClass.objects.get(id=self.objs[0].id)
        self.assertEqual(obj.val, 5)
Try to post to a view protected by an object permission. Should redirect
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/permissions/tests/tests.py/TestRequests.test_protected_post