<commit_before># MIT License
# Copyright (c) 2017 MassChallenge, Inc.
from datetime import timedelta

from django.utils import timezone

from impact.tests.factories import (
    BaseProfileFactory,
    EntrepreneurProfileFactory,
    ExpertProfileFactory,
    IndustryFactory,
    MemberProfileFactory,
    UserFactory,
)


class UserContext(object):
    def __init__(self,
                 user_type="ENTREPRENEUR",
                 primary_industry=None,
                 additional_industries=None,
                 functional_expertise=None,
                 program_families=[]):
        user = UserFactory(date_joined=(timezone.now() + timedelta(-10)))
        self.user = user
        self.program_families = program_families
        self.baseprofile = BaseProfileFactory(user=user, user_type=user_type)
        if user_type == "ENTREPRENEUR":
            self.profile = EntrepreneurProfileFactory(
                user=user,
                program_families=self.program_families)
            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)
            user.expertprofile = self.profile
        elif user_type == "MEMBER":
            self.profile = MemberProfileFactory(user=self.user)
            user.memberprofile = self.profile
        user.save()<commit_msg>[AC-7430] update user context to take program<commit_after># MIT License
# Copyright (c) 2017 MassChallenge, Inc.
from datetime import timedelta

from django.utils import timezone

from impact.tests.factories import (
    BaseProfileFactory,
    EntrepreneurProfileFactory,
    ExpertProfileFactory,
    IndustryFactory,
    MemberProfileFactory,
    UserFactory,
    ProgramRoleFactory,
    ProgramRoleGrantFactory,
)


class UserContext(object):
    def __init__(self,
                 user_type="ENTREPRENEUR",
                 primary_industry=None,
                 additional_industries=None,
                 functional_expertise=None,
                 program_families=[],
                 program=None):
        user = UserFactory(date_joined=(timezone.now() + timedelta(-10)))
        self.user = user
        self.program_families = program_families
        self.baseprofile = BaseProfileFactory(user=user, user_type=user_type)
        self.program = program
        if user_type == "ENTREPRENEUR":
            self.profile = EntrepreneurProfileFactory(
                user=user,
                program_families=self.program_families)
            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)
            user.expertprofile = self.profile
        elif user_type == "MEMBER":
            self.profile = MemberProfileFactory(user=self.user)
            user.memberprofile = self.profile
        if program:
            self.program_role = ProgramRoleFactory(program=self.program)
            self.program_role_grant = ProgramRoleGrantFactory(
                person=self.user,
                program_role=self.program_role)
        user.save()
{'fraction_non_alphanumeric': 0.0728215255492471, 'fraction_numerical': 0.003949642063687978, 'mean_word_length': 2.390794979079498, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6264568', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1017, 'n_words': 184}