def test_basic_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user)
     startup = member.startup
     startup.additional_industries.add(IndustryFactory())
     program = ProgramFactory()
     program_status = StartupStatusFactory(
         program_startup_status__program=program,
         program_startup_status__badge_display=BADGE_DISPLAYS[0],
         program_startup_status__startup_list_include=True,
         startup=startup).program_startup_status.startup_status
     other_status = StartupStatusFactory(
         program_startup_status__program=ProgramFactory(),
         program_startup_status__badge_display=BADGE_DISPLAYS[0],
         program_startup_status__startup_list_include=True,
         startup=startup).program_startup_status.startup_status
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         assert startup.name == response.data["name"]
         statuses = [
             status["status_name"] for status in response.data["statuses"]
         ]
         assert program_status in statuses
         assert other_status not in statuses
Beispiel #2
0
 def test_missing_startup(self):
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         url = reverse("startup_detail")
         response = self.client.post(url, {"ProgramKey": program.id})
         assert response.status_code == 404
         assert match_errors({"StartupKey": "'None'"}, response.data)
 def test_missing_startup(self):
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL,
                                     {"ProgramKey": program.id})
         assert response.status_code == 404
         assert match_errors({"StartupKey": "'None'"}, response.data)
Beispiel #4
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"])
Beispiel #5
0
 def test_options(self):
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(ProgramDetailView.view_name, args=[program.id])
         response = self.client.options(url)
         assert response.status_code == 200
         get_options = response.data["actions"]["GET"]["properties"]
         assert_fields(PROGRAM_GET_FIELDS, get_options)
Beispiel #6
0
 def test_get(self):
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(ProgramDetailView.view_name, args=[program.id])
         response = self.client.get(url)
         assert response.data["name"] == program.name
         assert response.data["cycle_name"] == program.cycle.name
         assert (response.data["program_family_name"] ==
                 program.program_family.name)
Beispiel #7
0
 def test_get(self):
     count = 5
     programs = ProgramFactory.create_batch(count)
     with self.login(email=self.basic_user().email):
         response = self.client.get(self.url)
         assert response.data["count"] == count
         assert all([
             ProgramListView.serialize(program) in response.data["results"]
             for program in programs
         ])
Beispiel #8
0
    def test_options_against_get(self):
        program = ProgramFactory()
        with self.login(email=self.basic_user().email):
            url = reverse(ProgramDetailView.view_name, args=[program.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_public_member_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user,
                                       display_on_public_profile=True)
     startup = member.startup
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         assert startup.name == response.data["name"]
 def test_url_slug_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user)
     startup = member.startup
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(
             STARTUP_DETAIL_URL, {
                 "ProgramKey": program.id,
                 "StartupKey": startup.organization.url_slug
             })
         assert startup.name == response.data["name"]
 def test_deleted_startup(self):
     startup = StartupFactory()
     startup_id = startup.id
     startup.delete()
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup_id
         })
         assert response.status_code == 404
         assert match_errors({"StartupKey": str(startup_id)}, response.data)
 def test_stealth_startup_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user,
                                       startup__is_visible=False)
     startup = member.startup
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         assert EMPTY_DETAIL_RESULT == response.data
 def test_unrecognized_video_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(
         user=context.user,
         display_on_public_profile=True,
         startup__video_elevator_pitch_url=UNKNOWN_VIDEO_EXAMPLE)
     startup = member.startup
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         assert "" == response.data["video_elevator_pitch_url"]
 def setUp(self):
     # Many objects must be created to scaffold this thing
     Site.objects.create()
     _site = Site.objects.first()
     startup1, startup2 = StartupFactory.create_batch(2)
     startup1.high_resolution_logo = "hamsterdance.gif"
     startup1.save()
     JobPostingFactory(startup=startup1)
     JobPostingFactory(startup=startup2)
     self.program = ProgramFactory()
     _pss = ProgramStartupStatusFactory(program=self.program)
     StartupStatusFactory(startup=startup1, program_startup_status=_pss)
     StartupStatusFactory(startup=startup2, program_startup_status=_pss)
     SiteProgramAuthorizationFactory(site=_site, program=self.program)
     self.url = reverse("job_posting_list")
Beispiel #15
0
 def test_bad_video_post(self):
     context = UserContext()
     member = StartupTeamMemberFactory(
         user=context.user,
         display_on_public_profile=True,
         startup__video_elevator_pitch_url=BAD_YOUTUBE_EXAMPLE)
     startup = member.startup
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         url = reverse("startup_detail")
         response = self.client.post(url, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         assert "" == response.data["video_elevator_pitch_url"]
 def test_logos_are_resized(self):
     path = "startup_pics/yuge.png"
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user)
     startup = member.startup
     startup.high_resolution_logo = path
     startup.save()
     program = ProgramFactory()
     with self.login(email=self.basic_user().email):
         response = self.client.post(STARTUP_DETAIL_URL, {
             "ProgramKey": program.id,
             "StartupKey": startup.id
         })
         url_base = (settings.IMAGE_RESIZE_HOST +
                     settings.IMAGE_RESIZE_TEMPLATE).format("")
         self.assertTrue(url_base in response.data["logo_url"])
Beispiel #17
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"])
Beispiel #18
0
 def test_str(self):
     program = ProgramFactory()
     assert str(program) == program.name