def test_study_class_receiver_counts_parents_list(self, profile_param):
        profile = getattr(self, profile_param)
        self.client.login(username=profile.username, password='******')

        # Create a parent without email and one without a phone_number
        student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                     student_in_class=self.study_class)
        parent = UserProfileFactory(user_role=UserProfile.UserRoles.PARENT,
                                    phone_number=None,
                                    use_phone_as_username=False)
        student.parents.add(parent)

        student1 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                      student_in_class=self.study_class)
        parent1 = UserProfileFactory(user_role=UserProfile.UserRoles.PARENT,
                                     username='******')
        parent1.email = None
        parent1.save()
        student1.parents.add(parent1)

        response = self.client.get(self.build_url(self.study_class.id),
                                   {'receiver_type': 'CLASS_PARENTS'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total_count'], 2)
        self.assertEqual(response.data['emails_count'], 1)
        self.assertEqual(response.data['phone_numbers_count'], 1)
    def test_study_class_receiver_counts_students_list(self, profile_param):
        profile = getattr(self, profile_param)
        self.client.login(username=profile.username, password='******')

        # Create a student without email and one without a phone_number
        UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                           student_in_class=self.study_class,
                           phone_number=None,
                           use_phone_as_username=False)
        profile = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                     student_in_class=self.study_class,
                                     username='******')
        profile.email = None
        profile.save()

        response = self.client.get(self.build_url(self.study_class.id))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total_count'], 2)
        self.assertEqual(response.data['emails_count'], 1)
        self.assertEqual(response.data['phone_numbers_count'], 1)

        # Create a student from another school
        school_unit = RegisteredSchoolUnitFactory()
        UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                           school_unit=school_unit)
        StudyClassFactory(school_unit=school_unit)

        response = self.client.get(self.build_url(self.study_class.id))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total_count'], 2)

        # Create a student from another class
        other_class = StudyClassFactory(school_unit=self.school_unit)
        UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                           school_unit=self.school_unit,
                           student_in_class=other_class)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['total_count'], 2)