def assertActionRequiresPermission(self, action, permission=None):
        """Assert that the given list action requires the given permission."""
        if permission is None:
            permission = self.perm

        o = self.factory.create()

        form = self.get_form()

        name = "action-{0}".format(action)

        # action button not shown to the user
        self.assertTrue(name not in form.fields)

        # ...but if they cleverly submit it anyway they get a 403...
        res = self.post(
            {
                name: str(o.id),
                "csrfmiddlewaretoken":
                    form.fields.get("csrfmiddlewaretoken")[0].value
                },
            status=403,
            )

        # ...with a message about permissions.
        res.mustcontain("permission")
dataset/ETHPy150Open mozilla/moztrap/tests/case/view/manage.py/ListViewTestCase.assertActionRequiresPermission/original