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_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"])
 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")
 def test_user_with_permissions_can_create_objects(self):
     url_name = "object-list"
     program_role = ProgramRoleFactory(id=1)
     startup_status = StartupStatusFactory(id=1)
     view_kwargs = {
         'app': 'accelerator',
         "model": "programrole",
     }
     self.response_401(self.get(url_name, **view_kwargs))
     program_role_permission, _ = Permission.objects.get_or_create(
         content_type=ContentType.objects.get(app_label='accelerator',
                                              model='programrole'),
         codename='add_programrole',
     )
     perm_user = self.make_user('*****@*****.**',
                                perms=["mc.add_programrole"])
     perm = PermissionFactory.create(codename='change_programrole')
     view_perm = PermissionFactory.create(codename='view_programrole')
     perm_user.user_permissions.add(perm)
     perm_user.user_permissions.add(program_role_permission)
     perm_user.user_permissions.add(view_perm)
     perm_user.save()
     self.assertFalse(
         ProgramRole.objects.filter(name="2011 - Final").exists())
     with self.login(perm_user):
         self.post(url_name,
                   data={
                       "name": "2011 - Final",
                       "program": program_role.id,
                       "user_role": startup_status.id
                   },
                   **view_kwargs)
         self.assertTrue(
             ProgramRole.objects.filter(name="2011 - Final").exists())
Beispiel #5
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_request_with_jobkey(self):
     job = JobPostingFactory()
     StartupStatusFactory(startup=job.startup)
     with self.login(email=self.basic_user().email):
         url = reverse("job_posting_detail")
         data = {"JobKey": job.pk}
         response = self.client.post(url, data=data)
         self.assertEqual(200, response.status_code)
 def test_image_token_no_smoke(self):
     job = JobPostingFactory()
     job.startup.high_resolution_logo = "hamsterdance.gif"
     job.startup.save()
     StartupStatusFactory(startup=job.startup)
     with self.login(email=self.basic_user().email):
         url = reverse("job_posting_detail")
         data = {"JobKey": job.pk}
         response = self.client.post(url, data=data)
         self.assertEqual(200, response.status_code)
 def test_post_without_program(self):
     context = UserContext()
     member = StartupTeamMemberFactory(user=context.user)
     startup = member.startup
     status1 = StartupStatusFactory(
         program_startup_status__badge_display=BADGE_DISPLAYS[0],
         program_startup_status__startup_list_include=True,
         startup=startup).program_startup_status.startup_status
     status2 = StartupStatusFactory(
         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,
                                     {"StartupKey": startup.id})
         assert startup.name == response.data["name"]
         statuses = [
             status["status_name"] for status in response.data["statuses"]
         ]
         assert status1 in statuses
         assert status2 in statuses
Beispiel #9
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_anonymous_user_cannot_create_object(self):
     url_name = "object-list"
     program_role = ProgramRoleFactory(id=1)
     startup_status = StartupStatusFactory(id=1)
     view_kwargs = {
         'app': 'accelerator',
         "model": "programrole",
     }
     response = self.post(url_name,
                          data={
                              "name": "2011 - Final",
                              "program": program_role.id,
                              "user_role": startup_status.id
                          },
                          **view_kwargs)
     self.response_401(response)
     self.assertFalse(
         ProgramRole.objects.filter(name="2011 - Final").exists())
Beispiel #11
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"])
Beispiel #12
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]
 def test_basic_user_without_permissions_cannot_create_object(self):
     url_name = "object-list"
     program_role = ProgramRoleFactory(id=1)
     startup_status = StartupStatusFactory(id=1)
     view_kwargs = {
         'app': 'accelerator',
         "model": "programrole",
     }
     basic_user = self.make_user('*****@*****.**')
     with self.login(basic_user):
         response = self.post(url_name,
                              data={
                                  "name": "2011 - Final",
                                  "program": program_role.id,
                                  "user_role": startup_status.id
                              },
                              **view_kwargs)
         self.response_403(response)
         self.assertFalse(
             ProgramRole.objects.filter(name="2011 - Final").exists())
Beispiel #14
0
 def test_user_with_permissions_can_create_objects(self):
     url_name = "object-list"
     StartupStatusFactory()
     view_kwargs = {
         'app': 'accelerator',
         "model": "startup",
     }
     self.response_401(self.get(url_name, **view_kwargs))
     startup_add_permission, _ = Permission.objects.get_or_create(
         content_type=ContentType.objects.get(app_label='accelerator',
                                              model='startup'),
         codename='add_startup',
     )
     perm_user = self.make_user('*****@*****.**')
     self._grant_permissions(perm_user,
                             model_name='startup',
                             permissions=['add', 'change', 'view'])
     org = OrganizationFactory()
     industry = IndustryFactory()
     self.assertFalse(Startup.objects.filter(organization=org).exists())
     with self.login(perm_user):
         self.post(url_name,
                   data={
                       "is_visible": False,
                       "full_elevator_pitch": "test",
                       "linked_in_url": "",
                       "short_pitch": "test",
                       "facebook_url": "",
                       "video_elevator_pitch_url": "",
                       "organization": org.id,
                       "user": perm_user.id,
                       "primary_industry": industry.id
                   },
                   **view_kwargs)
         org_query = Startup.objects.filter(organization=org)
         self.assertTrue(org_query.exists())
         self.assertTrue(
             org_query.first().primary_industry.id == industry.id)