Exemple #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"])
Exemple #2
0
 def test_options(self):
     application = ApplicationFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(ApplicationDetailView.view_name,
                       args=[application.id])
         response = self.client.options(url)
         assert response.status_code == 200
         get_options = response.data["actions"]["GET"]["properties"]
         assert_fields(APPLICATION_GET_FIELDS, get_options)
Exemple #3
0
 def test_get(self):
     count = 5
     applications = ApplicationFactory.create_batch(count)
     with self.login(email=self.basic_user().email):
         response = self.client.get(self.url)
         assert response.data["count"] == count
         assert all([
             ApplicationListView.serialize(application)
             in response.data["results"] for application in applications
         ])
Exemple #4
0
    def test_options_against_get(self):
        application = ApplicationFactory()
        with self.login(email=self.basic_user().email):
            url = reverse(ApplicationDetailView.view_name,
                          args=[application.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))
Exemple #5
0
 def test_get(self):
     application = ApplicationFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(ApplicationDetailView.view_name,
                       args=[application.id])
         response = self.client.get(url)
         assert response.data["created_at"] == application.created_at
         assert response.data["updated_at"] == application.updated_at
         assert (response.data["application_status"] ==
                 application.application_status)
         assert response.data["cycle"] == application.cycle.id
         assert response.data["startup"] == application.startup.id
         assert (response.data["application_type"] ==
                 application.application_type.id)
Exemple #6
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"])
Exemple #7
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))
Exemple #8
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"])