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)
评论列表
文章目录