'Tests that get_user_module_for_noauth succeeds when rebind_noauth_module_to_user is run from a
module bound to AnonymousUser'

def test_rebind_noauth_module_to_user_anonymous(self):

    module = self.get_module_for_user(self.anon_user)
    user2 = UserFactory()
    user2.id = 2
    module.system.rebind_noauth_module_to_user(module, user2)
    self.assertTrue(module)
    self.assertEqual(module.system.anonymous_student_id, anonymous_id_for_user(user2, self.course.id))
    self.assertEqual(module.scope_ids.user_id, user2.id)
    self.assertEqual(module.descriptor.scope_ids.user_id, user2.id)
