Exemplo n.º 1
0
 def test_rebind_noauth_module_to_user_anonymous(self):
     """
     Tests that get_user_module_for_noauth succeeds when rebind_noauth_module_to_user is run from a
     module bound to AnonymousUser
     """
     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)
Exemplo n.º 2
0
 def test_rebind_noauth_module_to_user_not_anonymous(self):
     """
     Tests that an exception is thrown when rebind_noauth_module_to_user is run from a
     module bound to a real user
     """
     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))