def test_join_groups(self): mixin = LTIAuthMixin() ctx = LTICourseContextFactory() user = UserFactory() mixin.join_groups(self.lti, ctx, user) self.assertTrue(user in ctx.group.user_set.all()) self.assertTrue(user in ctx.faculty_group.user_set.all())
def test_join_groups_student(self): mixin = LTIAuthMixin() ctx = LTICourseContextFactory() user = UserFactory() self.lti.lti_params['roles'] = u'Learner' mixin.join_groups(self.lti, ctx, user) self.assertTrue(user in ctx.group.user_set.all()) self.assertFalse(user in ctx.faculty_group.user_set.all())
def test_join_groups_teachingassistant(self): mixin = LTIAuthMixin() ctx = LTICourseContextFactory() user = UserFactory() self.lti.lti_params['roles'] = \ u'urn:lti:role:ims/lis/TeachingAssistant' mixin.join_groups(self.lti, ctx, user) self.assertTrue(user in ctx.group.user_set.all()) self.assertFalse(user in ctx.faculty_group.user_set.all()) with self.settings(LTI_ELEVATE_TEACHINGASSISTANTS=['instructure.edu']): mixin.join_groups(self.lti, ctx, user) self.assertTrue(user in ctx.group.user_set.all()) self.assertTrue(user in ctx.faculty_group.user_set.all())
def test_get_user(self): user = UserFactory() self.assertIsNone(self.backend.get_user(1234)) self.assertEquals(self.backend.get_user(user.id), user)
def test_find_or_create_user3(self): # via hashed username self.lti.lti_params['oauth_consumer_key'] = '1234567890' username = self.backend.get_hashed_username(self.lti) user = UserFactory(username=username) self.assertEquals(self.backend.find_or_create_user(self.lti), user)
def test_find_or_create_user2(self): # via lms username username = '******' self.lti.lti_params['custom_canvas_user_login_id'] = username user = UserFactory(username=username) self.assertEquals(self.backend.find_or_create_user(self.lti), user)
def test_find_or_create_user1(self): # via email user = UserFactory(email='*****@*****.**') self.assertEquals(self.backend.find_or_create_user(self.lti), user)