'Tests that an exception is thrown when rebind_noauth_module_to_user is run from a
module bound to a real user'

def test_rebind_noauth_module_to_user_not_anonymous(self):

    module = self.get_module_for_user(self.user)
    user2 = UserFactory()
    user2.id = 2
    with self.assertRaisesRegexp(render.LmsModuleRenderError, 'rebind_noauth_module_to_user    can    only    be    called    from    a    module    bound    to    an    anonymous    user'):
        self.assertTrue(module.system.rebind_noauth_module_to_user(module, user2))
