Ejemplo n.º 1
0
 def test_has_specific_team_access_protected_team(self, username, expected_return):
     user = self.users[username]
     try:
         self.assertEqual(
             expected_return,
             teams_api.has_specific_team_access(user, self.team_protected_1)
         )
     except ValueError:
         self.assertFalse(CourseEnrollment.is_enrolled(user, self.team_protected_1.course_id))
Ejemplo n.º 2
0
    def add_user(self, user):
        """Adds the given user to the CourseTeam."""
        from lms.djangoapps.teams.api import has_specific_team_access

        if not CourseEnrollment.is_enrolled(user, self.course_id):
            raise NotEnrolledInCourseForTeam
        if CourseTeamMembership.user_in_team_for_course(
                user, self.course_id, self.topic_id):
            raise AlreadyOnTeamInCourse
        if not has_specific_team_access(user, self):
            raise AddToIncompatibleTeamError
        return CourseTeamMembership.objects.create(user=user, team=self)
Ejemplo n.º 3
0
 def test_has_specific_team_access_protected_team(self, username, expected_return):
     user = self.users[username]
     try:
         assert expected_return == teams_api.has_specific_team_access(user, self.team_protected_1)
     except ValueError:
         assert not CourseEnrollment.is_enrolled(user, self.team_protected_1.course_id)