def test_user_became_judge_with_no_cycle_deadline(self):
     user_date = days_from_now(-4)
     user = UserFactory(date_joined=user_date)
     cycle = ProgramCycleFactory(application_final_deadline_date=None)
     prg = ProgramRoleGrantFactory(
         person=user,
         program_role__program__cycle=cycle,
         program_role__user_role__name=UserRole.JUDGE)
     prg.created_at = None
     prg.save()
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameConfirmedJudgeEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(user_date, events[0]["datetime"])
 def test_user_became_desired_mentor(self):
     prg = ProgramRoleGrantFactory(
         program_role__user_role__name=UserRole.DESIRED_MENTOR)
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameDesiredMentorEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(prg.created_at, events[0]["datetime"])
 def test_get_user_latest_active_program_location(self):
     role_grant = ProgramRoleGrantFactory(
         program_role__program__program_status=ACTIVE_PROGRAM_STATUS)
     user = role_grant.person
     user_program = role_grant.program_role.program
     with self.login(email=self.basic_user().email):
         url = reverse(UserDetailView.view_name, args=[user.id])
         response = self.client.get(url)
         program_location = response.data['latest_active_program_location']
         assert user_program.program_family.name == program_location
    def test_get_user_confirmed_program_families(self):
        role_grant = ProgramRoleGrantFactory(
            program_role__program__program_status=ACTIVE_PROGRAM_STATUS, )
        user = role_grant.person
        user_program = role_grant.program_role.program
        with self.login(email=self.basic_user().email):
            url = reverse(UserDetailView.view_name, args=[user.id])
            response = self.client.get(url)
            confirmed_program_families = response.data[
                'confirmed_user_program_families']

            keys = confirmed_program_families.keys()
            assert user_program.program_family.name in keys
 def test_user_became_finalist(self):
     prg = ProgramRoleGrantFactory(
         program_role__user_role__name=UserRole.FINALIST)
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameFinalistEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(prg.created_at, events[0]["datetime"])
         self.assertEqual(prg.program_role.program.name,
                          events[0]["program"])
         self.assertEqual(prg.program_role.program.cycle.name,
                          events[0]["cycle"])
 def test_user_became_desired_judge(self):
     prg = ProgramRoleGrantFactory(
         program_role__user_role__name=UserRole.DESIRED_JUDGE)
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameDesiredJudgeEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         format_string = UserBecameDesiredJudgeEvent.PROGRAM_ROLE_FORMAT
         self.assertEqual(
             format_string.format(
                 role_name=UserBecameDesiredJudgeEvent.ROLE_NAME,
                 name=prg.program_role.name,
                 id=prg.program_role.id), events[0]["description"])
    def test_get_user_with_no_created_at_in_prgs_handled(self):
        role_grant = ProgramRoleGrantFactory(
            program_role__program__program_status=ACTIVE_PROGRAM_STATUS, )
        user = role_grant.person
        user_program = role_grant.program_role.program

        role_grant2 = ProgramRoleGrantFactory(
            person=user,
            program_role__program__program_status=ACTIVE_PROGRAM_STATUS,
        )

        role_grant.created_at = None
        role_grant2.created_at = None

        role_grant.save()
        role_grant2.save()

        with self.login(email=self.basic_user().email):
            url = reverse(UserDetailView.view_name, args=[user.id])
            response = self.client.get(url)
            confirmed_program_families = response.data[
                'confirmed_user_program_families']
            keys = confirmed_program_families.keys()
            assert user_program.program_family.name in keys
 def test_user_became_confirmed_judge_with_cycle_based_judging_round(self):
     prg = ProgramRoleGrantFactory(
         program_role__user_role__name=UserRole.JUDGE)
     jr = JudgingRoundFactory(
         confirmed_judge_label=prg.program_role.user_label,
         cycle_based_round=True)
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameConfirmedJudgeEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         format_string = UserBecameConfirmedJudgeEvent.JUDGING_ROUND_FORMAT
         self.assertEqual(
             format_string.format(
                 role_name=UserBecameConfirmedJudgeEvent.ROLE_NAME,
                 name=jr.short_name(),
                 id=jr.id), events[0]["description"])
예제 #9
0
 def __init__(self,
              user_type="ENTREPRENEUR",
              primary_industry=None,
              additional_industries=None,
              functional_expertise=None,
              program_families=None,
              program_role_names=None,
              startup_status_names=None):
     self.user = UserFactory(date_joined=(timezone.now() + timedelta(-10)))
     self.program_families = program_families or []
     self.program_role_names = program_role_names or []
     self.startup_status_names = startup_status_names or []
     self.baseprofile = BaseProfileFactory(user=self.user,
                                           user_type=user_type)
     if user_type == "ENTREPRENEUR":
         self.profile = EntrepreneurProfileFactory(
             user=self.user,
             program_families=self.program_families)
         self.user.entrepreneurprofile = self.profile
     elif user_type == "EXPERT":
         self.primary_industry = primary_industry or IndustryFactory()
         self.additional_industries = additional_industries or []
         self.functional_expertise = functional_expertise or []
         self.profile = ExpertProfileFactory(
             user=self.user,
             primary_industry=self.primary_industry,
             additional_industries=self.additional_industries,
             functional_expertise=self.functional_expertise,
             program_families=self.program_families)
         self.user.expertprofile = self.profile
     elif user_type == "MEMBER":
         self.profile = MemberProfileFactory(user=self.user)
         self.user.memberprofile = self.profile
     self.user.save()
     self.program_role_grants = [
         ProgramRoleGrantFactory(person=self.user,
                                 program_role__user_role__name=role_name)
         for role_name in self.program_role_names]
     self.startup_role_grants = [
         StartupStatusFactory(
             startup__user=self.user,
             program_startup_status__startup_role__name=status_name)
         for status_name in self.startup_status_names]