예제 #1
0
    def test_finalist_user_gets_all_programs_in_past_or_present(self):
        programs = _create_batch_program_and_named_group(
            ACTIVE_PROGRAM_STATUS, 5)
        other_program = ProgramFactory(
            program_status=UPCOMING_PROGRAM_STATUS,
            mentor_program_group=NamedGroupFactory())
        program = programs[0]
        user = self._create_user_with_role_grant(program, UserRole.FINALIST)
        response_data = self._get_response_data(user,
                                                self._mentor_directory_url())

        for program in programs:
            self.assertIn(program.name, response_data["filters"])
        self.assertNotIn(other_program.name, response_data["filters"])
예제 #2
0
    def test_alumni_user_who_is_also_finalist_sees_mentors_of_both_programs(
            self):
        programs = _create_batch_program_and_named_group(
            ACTIVE_PROGRAM_STATUS, 5)
        named_alumni_group = NamedGroupFactory()
        other_program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS,
                                       mentor_program_group=named_alumni_group)
        finalist_program = programs[1]
        user = self._create_user_with_role_grant(other_program, UserRole.ALUM)
        self._create_user_with_role_grant(finalist_program, UserRole.FINALIST,
                                          user)
        response_data = self._get_response_data(user,
                                                self._mentor_directory_url())

        for program in programs:
            self.assertIn(program.name, response_data["filters"])
        self.assertIn(other_program.name, response_data["filters"])
    def test_non_participant_user_sees_all_confirmed_mentors(self):
        named_group = NamedGroupFactory()
        programs = []
        for _ in range(5):
            programs.append(
                ProgramFactory(mentor_program_group=named_group,
                               program_status=ACTIVE_PROGRAM_STATUS))
        program = programs[0]
        user = self._create_user_with_role_grant(program,
                                                 UserRole.DESIRED_MENTOR)
        with self.settings(ALGOLIA_APPLICATION_ID='test',
                           ALGOLIA_API_KEY='test'):
            with self.login(email=user.email):
                response = self.client.get(self.url)
                response_data = json.loads(response.content)

                self.assertIn(IS_CONFIRMED_MENTOR_FILTER,
                              response_data["filters"])
    def test_finalist_user_gets_all_programs_in_program_group(self):
        named_group = NamedGroupFactory()
        programs = []
        for _ in range(5):
            programs.append(
                ProgramFactory(mentor_program_group=named_group,
                               program_status=ACTIVE_PROGRAM_STATUS))
        other_program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS)
        program = programs[0]
        user = self._create_user_with_role_grant(program, UserRole.FINALIST)
        with self.settings(ALGOLIA_APPLICATION_ID='test',
                           ALGOLIA_API_KEY='test'):
            with self.login(email=user.email):
                response = self.client.get(self.url)
                response_data = json.loads(response.content)

                for program in programs:
                    self.assertIn(program.name, response_data["filters"])
                self.assertNotIn(other_program.name, response_data["filters"])
예제 #5
0
def _create_batch_program_and_named_group(status, batch_size):
    named_group = NamedGroupFactory()
    programs = ProgramFactory.create_batch(batch_size,
                                           mentor_program_group=named_group,
                                           program_status=status)
    return programs