def test_get_industry_with_parent(self):
     parent = IndustryFactory()
     industry = IndustryFactory(parent=parent)
     with self.login(email=self.basic_user().email):
         url = reverse(IndustryDetailView.view_name, args=[industry.id])
         response = self.client.get(url)
         assert response.data["name"] == industry.name
         assert response.data["parent_id"] == industry.parent_id
         assert response.data["full_name"] == str(industry)
 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
示例#3
0
 def __init__(self,
              user_type="ENTREPRENEUR",
              primary_industry=None,
              additional_industries=None,
              functional_expertise=None):
     user = UserFactory(date_joined=(timezone.now() + timedelta(-10)))
     self.user = user
     self.baseprofile = BaseProfileFactory(user=user, user_type=user_type)
     if user_type == "ENTREPRENEUR":
         self.profile = EntrepreneurProfileFactory(user=user)
         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)
         user.expertprofile = self.profile
     elif user_type == "MEMBER":
         self.profile = MemberProfileFactory(user=self.user)
         user.memberprofile = self.profile
     user.save()
 def test_options(self):
     industry = IndustryFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(IndustryDetailView.view_name, args=[industry.id])
         response = self.client.options(url)
         assert response.status_code == 200
         get_options = response.data["actions"]["GET"]["properties"]
         assert_fields(MPTT_FIELDS.keys(), get_options)
 def test_get_expert_with_industries(self):
     primary_industry = IndustryFactory()
     additional_industries = IndustryFactory.create_batch(2)
     context = UserContext(user_type=EXPERT_USER_TYPE,
                           primary_industry=primary_industry,
                           additional_industries=additional_industries)
     user = context.user
     with self.login(email=self.basic_user().email):
         url = reverse(UserDetailView.view_name, args=[user.id])
         response = self.client.get(url)
         assert (response.data["primary_industry"]["id"] ==
                 primary_industry.id)
         additional_industry_ids = [
             datum["id"] for datum
             in response.data["additional_industries"]]
         assert all([industry.id in additional_industry_ids
                     for industry in additional_industries])
示例#6
0
 def test_get_startup_with_industries(self):
     primary_industry = IndustryFactory()
     additional_industries = IndustryFactory.create_batch(2)
     startup = StartupFactory(primary_industry=primary_industry,
                              additional_industries=additional_industries)
     with self.login(email=self.basic_user().email):
         url = reverse(OrganizationDetailView.view_name,
                       args=[startup.organization.id])
         response = self.client.get(url)
         assert (
             response.data["primary_industry"]["id"] == primary_industry.id)
         additional_industry_ids = [
             datum["id"] for datum in response.data["additional_industries"]
         ]
         assert all([
             industry.id in additional_industry_ids
             for industry in additional_industries
         ])
 def test_get_industries(self):
     count = 5
     industries = IndustryFactory.create_batch(count)
     with self.login(email=self.basic_user().email):
         response = self.client.get(self.url)
         assert response.data['count'] == count
         assert all([
             IndustryListView.serialize(industry)
             in response.data['results'] for industry in industries
         ])
    def test_options_against_get(self):
        industry = IndustryFactory()
        with self.login(email=self.basic_user().email):
            url = reverse(IndustryDetailView.view_name, args=[industry.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))
示例#9
0
def _example_expert(**kwargs):
    result = EXAMPLE_MEMBER.copy()
    result.update(kwargs)
    if "home_program_family_id" not in result:
        result["home_program_family_id"] = ProgramFamilyFactory().id
    if "primary_industry_id" not in result:
        result["primary_industry_id"] = IndustryFactory().id
    if "expert_category" not in result:
        result["expert_category"] = ExpertCategoryFactory().name
    result.update(EXAMPLE_EXPERT)
    return result
 def test_patch_ids(self):
     context = UserContext(user_type=EXPERT_USER_TYPE)
     user = context.user
     profile = get_profile(user)
     industry = IndustryFactory()
     program_family = ProgramFamilyFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(UserDetailView.view_name, args=[user.id])
         self.client.patch(url, {
             "home_program_family_id": program_family.id,
             "primary_industry_id": industry.id,
         })
         user.refresh_from_db()
         profile.refresh_from_db()
         helper = UserHelper(user)
         assert (helper.field_value("home_program_family_id") ==
                 program_family.id)
         assert (helper.profile_helper.subject.primary_industry_id ==
                 industry.id)
示例#11
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]