def test_staff_user_sees_staff_hours(self):
     program = ProgramFactory()
     staff_user = self.staff_user(program_family=program.program_family)
     staff_mentor = self.staff_user(program_family=program.program_family)
     office_hour = self.create_office_hour(mentor=staff_mentor)
     response = self.get_response(user=staff_user)
     self.assert_hour_in_response(response, office_hour)
Beispiel #2
0
 def setUp(self):
     self.program = ProgramFactory()
     ProgramRoleFactory(user_role=get_user_role_by_name(UserRole.MENTOR),
                        program=self.program)
     ProgramRoleFactory(user_role=get_user_role_by_name(
         UserRole.DEFERRED_MENTOR),
                        program=self.program)
 def test_program_family_for_staff_with_clearance_in_response(self):
     program_family = ProgramFactory().program_family
     staff_user = self.staff_user(program_family=program_family)
     self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=staff_user)
     mentor_program_families = response.data['mentor_program_families']
     self.assertTrue(program_family.name in mentor_program_families)
 def test_current_finalist_sees_current_open_hours(self):
     program = ProgramFactory()
     finalist = _finalist(program=program)
     mentor = _mentor(program=program)
     office_hour = self.create_office_hour(mentor=mentor)
     response = self.get_response(user=finalist)
     self.assert_hour_in_response(response, office_hour)
 def assert_user_with_clearance_sees_own_office_hour(self, clearance_level):
     program = ProgramFactory()
     staff_user = self.staff_user(program_family=program.program_family,
                                  level=clearance_level)
     office_hour = self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=staff_user)
     self.assert_hour_in_response(response, office_hour)
 def test_current_finalist_sees_staff_hours(self):
     program = ProgramFactory()
     finalist = _finalist(program=program)
     staff_user = self.staff_user(program_family=program.program_family)
     office_hour = self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=finalist)
     self.assert_hour_in_response(response, office_hour)
 def test_staff_sees_current_open_hours_for_their_program(self):
     program = ProgramFactory()
     staff_user = self.staff_user(program_family=program.program_family)
     mentor = _mentor(program=program)
     office_hour = self.create_office_hour(mentor=mentor)
     response = self.get_response(user=staff_user)
     self.assert_hour_in_response(response, office_hour)
 def test_staff_sees_own_office_hour_flag_for_their_hours(self):
     program = ProgramFactory()
     staff_user = self.staff_user(program_family=program.program_family)
     _mentor(program=program, user=staff_user)
     self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=staff_user)
     office_hour_data = response.data['calendar_data'][0]
     self.assertTrue(office_hour_data['own_office_hour'])
 def assert_user_with_clearance_can_create_office_hours(
         self, clearance_level):
     program_family = ProgramFactory().program_family
     staff_user = self.staff_user(program_family=program_family,
                                  level=clearance_level)
     data = self._get_post_request_data(staff_user)
     with self._assert_office_hour_created():
         self._create_office_hour_session(staff_user, data)
    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"])
 def test_location_choices_doesnt_include_null_location_values(self):
     program_family_location = ProgramFamilyLocationFactory()
     program_family = program_family_location.program_family
     program_family_location.location.delete()
     ProgramFactory(program_family=program_family)
     staff_user = self.staff_user(program_family=program_family)
     self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=staff_user)
     location_choices = response.data['location_choices']
     self.assertEqual([], location_choices)
Beispiel #12
0
    def test_finalist_user_gets_all_programs_in_program_group(self):
        programs = _create_batch_program_and_named_group(
            ACTIVE_PROGRAM_STATUS, 5)
        other_program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS)
        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"])
 def test_location_choices_for_staff_with_clearance_in_response(self):
     program_family_location = ProgramFamilyLocationFactory()
     program_family = program_family_location.program_family
     location = program_family_location.location
     ProgramFactory(program_family=program_family)
     staff_user = self.staff_user(program_family=program_family)
     self.create_office_hour(mentor=staff_user)
     response = self.get_response(user=staff_user)
     location_choices = response.data['location_choices']
     response_location_names = [
         location['location_name'] for location in location_choices
     ]
     self.assertTrue(location.name in response_location_names)
 def test_get_program_filter(self):
     context = AnalyzeJudgingContext(type="matching",
                                     name="program",
                                     read_count=1)
     count = 4
     options = ProgramFactory.create_batch(count, cycle=context.cycle)
     context.add_applications(context.scenario.panel_size * count,
                              programs=options)
     judge_option = options[0].program_family
     judge = ExpertFactory(profile__home_program_family=judge_option)
     context.add_judge(assigned=False, complete=False, judge=judge)
     field = "startup__startupprograminterest__program__program_family"
     apps = Application.objects.filter(**{
         field: judge_option
     }).values_list("id", flat=True)
     self.assert_matching_allocation(context.judging_round, judge, apps)
Beispiel #15
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_get_program_filter_multiple_startup_interests(self):
     context = AnalyzeJudgingContext(type="matching",
                                     name="program",
                                     read_count=1)
     count = 4
     options = ProgramFactory.create_batch(count, cycle=context.cycle)
     panel_size = context.scenario.panel_size
     context.add_applications(panel_size * count, programs=options)
     judge_option = options[0].program_family
     judge = ExpertFactory(profile__home_program_family=judge_option)
     context.add_judge(assigned=False, complete=False, judge=judge)
     programs = chain(options[1:], options * panel_size)
     for app, program in zip(context.applications, programs):
         StartupProgramInterestFactory(startup=app.startup,
                                       program=program,
                                       order=2)
     spis = StartupProgramInterest.objects.filter(order=1,
                                                  program__in=options)
     app_filter = {"startup__startupprograminterest__in": spis}
     apps = Application.objects.filter(**app_filter).values_list("id",
                                                                 flat=True)
     self.assert_matching_allocation(context.judging_round, judge, apps)
Beispiel #18
0
 def test_finalist_user_filter_includes_is_active_filter(self):
     program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS)
     user = self._create_user_with_role_grant(program, UserRole.FINALIST)
     response_data = self._get_response_data(user,
                                             self._person_directory_url())
     self.assertIn(IS_ACTIVE_FILTER, response_data["filters"])
Beispiel #19
0
def _create_program_role_grant_for_role(role, user, program=None):
    return ProgramRoleGrantFactory(
        person=user,
        program_role__program=program or ProgramFactory(),
        program_role__user_role=get_user_role_by_name(role))
def _user_with_role(role_name, program, user):
    program = program or ProgramFactory()
    return UserRoleContext(role_name, program=program, user=user).user
Beispiel #21
0
 def test_alumni_finalist_mentors_view_finalist_startups(self):
     program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS)
     user = self._create_user_with_role_grant(program, UserRole.FINALIST)
     response_data = self._get_response_data(user,
                                             self._startup_directory_url())
     self.assertIn(IS_FINALIST, response_data["filters"])
Beispiel #22
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
 def _expert_with_inactive_program(self, role):
     program = ProgramFactory(program_status='ended')
     return self._expert_user(role, program)
 def test_staff_sees_only_relevant_open_hours(self):
     program = ProgramFactory()
     staff_user = self.staff_user(program_family=program.program_family)
     office_hour = self.create_office_hour()
     response = self.get_response(staff_user)
     self.assert_hour_not_in_response(response, office_hour)
Beispiel #25
0
 def test_finalist_user_response_has_programs_finalist_in(self):
     program = ProgramFactory(program_status=ACTIVE_PROGRAM_STATUS)
     user = self._create_user_with_role_grant(program, UserRole.FINALIST)
     response_data = self._get_response_data(user,
                                             self._mentor_directory_url())
     self.assertIn(program.id, response_data["finalist_programs"])
 def test_current_finalist_sees_only_relevant_open_hours(self):
     program = ProgramFactory()
     finalist = _finalist(program=program)
     office_hour = self.create_office_hour()
     response = self.get_response(user=finalist)
     self.assert_hour_not_in_response(response, office_hour)