'Test that a new anonymous id is returned when the secret key changes.'

def test_secret_key_changes(self):

    CourseEnrollment.enroll(self.user, self.course.id)
    anonymous_id = anonymous_id_for_user(self.user, self.course.id)
    with override_settings(SECRET_KEY='some_new_and_totally_secret_key'):
        self.user = User.objects.get(pk=self.user.id)
        new_anonymous_id = anonymous_id_for_user(self.user, self.course.id)
        self.assertNotEqual(anonymous_id, new_anonymous_id)
        self.assertEqual(self.user, user_by_anonymous_id(anonymous_id))
        self.assertEqual(self.user, user_by_anonymous_id(new_anonymous_id))
