Beispiel #1
0
    def test_admin_or_staff_list_students(self):
        expected_content = ag_serializers.UserSerializer(
            self.students, many=True).data

        for user in self.staff, self.admin:
            self.do_list_objects_test(
                self.client, user, self.url, expected_content)
    def test_error_admin_remove_self_from_admin_list(self):
        self.client.force_authenticate(self.remaining_admin)
        response = self.client.patch(
            self.url, {
                'remove_admins':
                ag_serializers.UserSerializer([self.remaining_admin],
                                              many=True).data
            })

        self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)

        self.assertTrue(self.course.is_admin(self.remaining_admin))
    def test_admin_or_staff_or_handgrader_list_staff(self):
        staff = obj_build.create_dummy_users(3)
        self.course.staff.add(*staff)

        expected_content = ag_serializers.UserSerializer(staff, many=True).data

        for user in self.admin, staff[0], self.handgrader:
            self.client.force_authenticate(user)

            response = self.client.get(self.url)

            self.assertEqual(status.HTTP_200_OK, response.status_code)
            self.assertCountEqual(expected_content, response.data)
    def setUp(self):
        super().setUp()

        self.remaining_admin = obj_build.create_dummy_user()
        self.current_admins = obj_build.create_dummy_users(3)
        self.all_admins = [self.remaining_admin] + self.current_admins
        self.total_num_admins = len(self.all_admins)

        self.course.admins.add(*self.all_admins)

        self.request_body = {
            'remove_admins':
            ag_serializers.UserSerializer(self.current_admins, many=True).data
        }
    def setUp(self):
        super().setUp()

        self.remaining_staff = obj_build.create_dummy_user()
        self.staff_to_remove = obj_build.create_dummy_users(3)
        self.all_staff = [self.remaining_staff] + self.staff_to_remove
        self.total_num_staff = len(self.all_staff)

        self.course.staff.add(*self.all_staff)

        self.request_body = {
            'remove_staff':
            ag_serializers.UserSerializer(self.staff_to_remove, many=True).data
        }
Beispiel #6
0
    def setUp(self):
        super().setUp()

        self.remaining_students = obj_build.create_dummy_users(2)
        self.students_to_remove = obj_build.create_dummy_users(5)
        self.all_enrolled = self.remaining_students + self.students_to_remove
        self.total_num_enrolled = len(self.all_enrolled)

        self.course.students.add(*self.all_enrolled)

        self.request_body = {
            'remove_students':
                ag_serializers.UserSerializer(self.students_to_remove, many=True).data
        }
Beispiel #7
0
    def setUp(self):
        super().setUp()

        self.remaining_handgraders = obj_build.create_dummy_users(2)
        self.handgraders_to_remove = obj_build.create_dummy_users(5)
        self.all_handgraders = self.remaining_handgraders + self.handgraders_to_remove
        self.total_num_handgraders = len(self.all_handgraders)

        self.course.handgraders.add(*self.all_handgraders)

        self.request_body = {
            "remove_handgraders":
            ag_serializers.UserSerializer(self.handgraders_to_remove,
                                          many=True).data
        }
 def current(self, request, *args, **kwargs):
     return response.Response(
         ag_serializers.UserSerializer(request.user).data)
Beispiel #9
0
    def test_admin_list_handgraders(self):
        expected_content = ag_serializers.UserSerializer(self.handgraders,
                                                         many=True).data

        self.do_list_objects_test(self.client, self.admin, self.url,
                                  expected_content)
 def test_self_get_user(self):
     for user in self.all_users:
         self.do_get_object_test(self.client, user, user_url(user),
                                 ag_serializers.UserSerializer(user).data)
 def test_self_get_currently_authenticated_user(self):
     for user in self.all_users:
         self.do_get_object_test(self.client, user, reverse('user-current'),
                                 ag_serializers.UserSerializer(user).data)