Example #1
0
 def test_startup_became_entrant(self):
     program = ProgramFactory()
     cycle = program.cycle
     application = ApplicationFactory(
         application_status=SUBMITTED_APP_STATUS,
         application_type=cycle.default_application_type,
         cycle=cycle)
     startup = application.startup
     StartupProgramInterestFactory(startup=startup,
                                   program=program,
                                   applying=True)
     startup_status = StartupStatusFactory(
         startup=startup,
         program_startup_status__program=program,
         program_startup_status__startup_role__name=StartupRole.ENTRANT)
     startup_status.created_at = days_from_now(-1)
     startup_status.save()
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameEntrantEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertTrue(cycle.name in events[0]["description"])
         self.assertEqual(startup_status.created_at, events[0]["datetime"])
         self.assertEqual(program.id, events[0]["program_id"])
         self.assertEqual(program.name, events[0]["program"])
         self.assertEqual(1, events[0]["program_preference"])
Example #2
0
 def test_organization_created(self):
     org = OrganizationFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name, args=[org.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationCreatedEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(org.created_at, events[0]["datetime"])
 def test_user_created(self):
     user = UserFactory(date_joined=timezone.now())
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[user.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserCreatedEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(user.date_joined, 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"])
Example #5
0
 def test_startup_created_no_created_datetime(self):
     startup = StartupFactory(created_datetime=None)
     startup.created_at = None
     startup.save()
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationCreatedEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(DAWN_OF_TIME, events[0]["datetime"])
 def test_user_joined_startup(self):
     stm = StartupTeamMemberFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[stm.user.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserJoinedStartupEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(stm.created_at, events[0]["datetime"])
         startup = stm.startup
         startup_str = UserJoinedStartupEvent.DESCRIPTION_FORMAT.format(
             name=startup.name, id=startup.organization.id)
         self.assertEqual(startup_str, events[0]["description"])
Example #7
0
 def test_startup_became_winner(self):
     startup = StartupFactory()
     startup_status = StartupStatusFactory(
         program_startup_status__startup_role__name=StartupRole.GOLD_WINNER,
         startup=startup)
     role = startup_status.program_startup_status.startup_role
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameWinnerEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(role.name, events[0]["winner_level"])
 def test_user_received_newsletter(self):
     receipt = NewsletterReceiptFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name,
                       args=[receipt.recipient.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserReceivedNewsletterEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(receipt.created_at, events[0]["datetime"])
         self.assertEqual(receipt.newsletter.name,
                          events[0]["newsletter_name"])
         self.assertEqual(receipt.newsletter.from_addr,
                          events[0]["newsletter_from_address"])
 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_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"])
Example #12
0
 def test_startup_became_winner_no_created_at(self):
     startup = StartupFactory()
     end_date = days_from_now(-10)
     startup_status = StartupStatusFactory(
         program_startup_status__startup_role__name=StartupRole.GOLD_WINNER,
         program_startup_status__program__end_date=end_date,
         startup=startup)
     startup_status.created_at = None
     startup_status.save()
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameWinnerEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(end_date, events[0]["datetime"])
 def test_user_joined_startup_no_created_at(self):
     join_date = days_from_now(-10)
     stm = StartupTeamMemberFactory(user__date_joined=join_date)
     stm.created_at = None
     stm.save()
     next_created_at = days_from_now(-1)
     next_stm = StartupTeamMemberFactory()
     next_stm.created_at = next_created_at
     next_stm.save()
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[stm.user.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserJoinedStartupEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(join_date, events[0]["datetime"])
         self.assertEqual(next_created_at, events[0]["latest_datetime"])
 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"])
Example #15
0
 def test_startup_became_finalist(self):
     startup = StartupFactory()
     startup_status = StartupStatusFactory(
         program_startup_status__startup_role__name=StartupRole.FINALIST,
         startup=startup)
     program = startup_status.program_startup_status.program
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameFinalistEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertTrue(program.name in events[0]["description"])
         self.assertEqual(program.name, events[0]["program"])
         self.assertEqual(program.id, events[0]["program_id"])
         self.assertEqual(program.cycle.name, events[0]["cycle"])
         self.assertEqual(program.cycle.id, events[0]["cycle_id"])
Example #16
0
 def test_startup_created_using_other_startups(self):
     prev_created_datetime = days_from_now(-10)
     StartupFactory(created_datetime=prev_created_datetime)
     startup = StartupFactory(created_datetime=None)
     startup.created_at = None
     startup.save()
     next_created_datetime = days_from_now(-2)
     StartupFactory(created_datetime=next_created_datetime)
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationCreatedEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(prev_created_datetime, events[0]["datetime"])
         self.assertEqual(next_created_datetime,
                          events[0]["latest_datetime"])
Example #17
0
 def test_startup_became_entrant_for_multiple_programs(self):
     cycle = ProgramCycleFactory()
     application = ApplicationFactory(
         application_status=SUBMITTED_APP_STATUS,
         application_type=cycle.default_application_type,
         cycle=cycle)
     startup = application.startup
     INTEREST_COUNT = 2
     StartupProgramInterestFactory.create_batch(INTEREST_COUNT,
                                                startup=startup,
                                                program__cycle=cycle,
                                                applying=True)
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameEntrantEvent.EVENT_TYPE)
         self.assertEqual(INTEREST_COUNT, len(events))
Example #18
0
 def test_startup_became_entrant_no_final_deadline(self):
     cycle = ProgramCycleFactory(application_final_deadline_date=None)
     application = ApplicationFactory(
         application_status=SUBMITTED_APP_STATUS,
         application_type=cycle.default_application_type,
         cycle=cycle,
         submission_datetime=None)
     startup = application.startup
     StartupProgramInterestFactory(startup=startup,
                                   program__cycle=cycle,
                                   applying=True)
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameEntrantEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(DAWN_OF_TIME, events[0]["datetime"])
Example #19
0
 def test_partner_created_using_later_partner(self):
     prev_partner = PartnerFactory()
     prev_created_at = days_from_now(-10)
     prev_partner.created_at = prev_created_at
     prev_partner.save()
     partner = PartnerFactory()
     partner.created_at = None
     partner.save()
     next_partner = PartnerFactory()
     next_created_at = days_from_now(-2)
     next_partner.created_at = next_created_at
     next_partner.save()
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[partner.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationCreatedEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertEqual(prev_created_at, events[0]["datetime"])
         self.assertEqual(next_created_at, events[0]["latest_datetime"])
Example #20
0
 def test_startup_became_entrant_no_startup_status(self):
     program = ProgramFactory()
     cycle = program.cycle
     submission_datetime = days_from_now(-2)
     application = ApplicationFactory(
         application_status=SUBMITTED_APP_STATUS,
         application_type=cycle.default_application_type,
         submission_datetime=submission_datetime,
         cycle=cycle)
     startup = application.startup
     StartupProgramInterestFactory(startup=startup,
                                   program=program,
                                   applying=True)
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationHistoryView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              OrganizationBecameEntrantEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         self.assertTrue(cycle.name in events[0]["description"])
         self.assertEqual(submission_datetime, events[0]["datetime"])