def test_options(self): program_cycle = ProgramCycleFactory() with self.login(email=self.basic_user().email): url = reverse(ProgramCycleDetailView.view_name, args=[program_cycle.id]) response = self.client.options(url) assert response.status_code == 200 get_options = response.data["actions"]["GET"]["properties"] assert_fields(PROGRAM_CYCLE_GET_FIELDS, get_options)
def test_get(self): program_cycle = ProgramCycleFactory() with self.login(email=self.basic_user().email): url = reverse(ProgramCycleDetailView.view_name, args=[program_cycle.id]) response = self.client.get(url) assert response.data["name"] == program_cycle.name assert (response.data["applications_open"] == program_cycle.applications_open)
def test_get(self): count = 5 cycles = ProgramCycleFactory.create_batch(count) with self.login(email=self.basic_user().email): response = self.client.get(self.url) assert response.data["count"] == count assert all([ ProgramCycleListView.serialize(cycle) in response.data["results"] for cycle in cycles ])
def test_options_against_get(self): program_cycle = ProgramCycleFactory() with self.login(email=self.basic_user().email): url = reverse(ProgramCycleDetailView.view_name, args=[program_cycle.id]) options_response = self.client.options(url) get_response = self.client.get(url) schema = options_response.data["actions"]["GET"] validator = Draft4Validator(schema) assert validator.is_valid(json.loads(get_response.content))
def test_startup_became_entrant_no_final_deadline_with_other_cycles(self): prev_deadline = days_from_now(-10) ProgramCycleFactory(application_final_deadline_date=prev_deadline) cycle = ProgramCycleFactory(application_final_deadline_date=None) next_deadline = days_from_now(-5) ProgramCycleFactory(application_final_deadline_date=next_deadline) 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(prev_deadline, events[0]["datetime"]) self.assertEqual(next_deadline, events[0]["latest_datetime"])
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_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))