signals_test.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:micromasters 作者: mitodl 项目源码 文件源码
def test_presave_removes_current_role(self):
        """
        Updating the role in the model triggers a pre_save
        signal that removes the previous role from the user.
        """
        mm_role = Role.objects.create(
            program=self.program,
            user=self.user,
            role='staff',
        )
        self.assert_standard_role_permissions(True)

        # muting the post_save signal to avoid the reassignment of the roles and related permissions
        # in this way only the pre_save will run and the effect will be only to remove the old role
        with mute_signals(post_save):
            mm_role.role = 'instructor'
            mm_role.save()
        self.assert_standard_role_permissions(False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号