<commit_before>import random
import os
from datetime import date, timedelta
from coolname import generate
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from django.conf import settings
from django.contrib.auth.models import Group
from django.db.models.signals import post_save
import factory
from factory import fuzzy
from faker import Faker

from account.models import User, UserProfile
from agency.agencies import AGENCIES
from agency.models import OtherAgency, Agency, AgencyOffice, AgencyMember
from agency.roles import AgencyRole
from common.models import Specialization, Point, AdminLevel1, CommonFile
from partner.models import (
    Partner,
    PartnerMailingAddress,
    PartnerDirector,
    PartnerAuthorisedOfficer,
    PartnerHeadOrganization,
    PartnerMandateMission,
    PartnerExperience,
    PartnerBudget,
    PartnerFunding,
    PartnerCollaborationPartnership,
    PartnerCollaborationEvidence,
    PartnerOtherInfo,
    PartnerInternalControl,
    PartnerPolicyArea,
    PartnerAuditAssessment,
    PartnerAuditReport,
    PartnerReporting,
    PartnerMember,
    PartnerCapacityAssessment,
    PartnerGoverningDocument,
    PartnerRegistrationDocument,
)
from partner.roles import PartnerRole
from project.identifiers import get_eoi_display_identifier
from project.models import EOI, Application, Assessment, EOIAttachment
from review.models import PartnerFlag, PartnerVerification
from common.consts import (
    PARTNER_TYPES,
    CONCERN_CHOICES,
    YEARS_OF_EXP_CHOICES,
    PARTNER_DONORS_CHOICES,
    COLLABORATION_EVIDENCE_MODES,
    FUNCTIONAL_RESPONSIBILITY_CHOICES,
    POLICY_AREA_CHOICES,
    ORG_AUDIT_CHOICES,
    AUDIT_ASSESSMENT_CHOICES,
    JUSTIFICATION_FOR_DIRECT_SELECTION,
    CFEI_TYPES,
    DIRECT_SELECTION_SOURCE,
    BUDGET_CHOICES,
    SELECTION_CRITERIA_CHOICES,
    STAFF_GLOBALLY_CHOICES,
    FINANCIAL_CONTROL_SYSTEM_CHOICES,
    WORKING_LANGUAGES_CHOICES,
)
from common.countries import COUNTRIES_ALPHA2_CODE
from sanctionslist.models import SanctionedNameMatch, SanctionedItem, SanctionedName

COUNTRIES = [x[0] for x in COUNTRIES_ALPHA2_CODE]

filename = os.path.join(settings.PROJECT_ROOT, 'apps', 'common', 'tests', 'test.doc')


fake = Faker()


def get_random_agency():
    return random.choice(AGENCIES).model_instance


def get_random_agency_office():
    return AgencyOffice.objects.order_by("?").first() or AgencyOfficeFactory()


def get_agency_member(agency=None):
    users_queryset = User.objects.filter(agency_members__isnull=False)
    if agency:
        users_queryset = users_queryset.filter(agency_members__office__agency=agency)

    member = users_queryset.order_by("?").first()
    if member:
        return member
    if agency:
        return AgencyMemberFactory(
            office=AgencyOfficeFactory(agency=agency)
        ).user
    else:
        return AgencyMemberFactory().user


def get_partner_member():
    member = User.objects.filter(is_superuser=False, partner_members__isnull=False).order_by("?").first()
    return member or PartnerMemberFactory().user


def get_new_common_file():
    cfile = CommonFile.objects.create()
    cfile.file_field.save('test.csv', open(filename))
    return cfile


def get_cfei_title():
    return f'Help the {generate(2)[-1].title()}'


def get_partner_name():<commit_msg>Change fakedata to generate longer project names<commit_after>import random
import os
from datetime import date, timedelta
from coolname import generate
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from django.conf import settings
from django.contrib.auth.models import Group
from django.db.models.signals import post_save
import factory
from factory import fuzzy
from faker import Faker

from account.models import User, UserProfile
from agency.agencies import AGENCIES
from agency.models import OtherAgency, Agency, AgencyOffice, AgencyMember
from agency.roles import AgencyRole
from common.models import Specialization, Point, AdminLevel1, CommonFile
from partner.models import (
    Partner,
    PartnerMailingAddress,
    PartnerDirector,
    PartnerAuthorisedOfficer,
    PartnerHeadOrganization,
    PartnerMandateMission,
    PartnerExperience,
    PartnerBudget,
    PartnerFunding,
    PartnerCollaborationPartnership,
    PartnerCollaborationEvidence,
    PartnerOtherInfo,
    PartnerInternalControl,
    PartnerPolicyArea,
    PartnerAuditAssessment,
    PartnerAuditReport,
    PartnerReporting,
    PartnerMember,
    PartnerCapacityAssessment,
    PartnerGoverningDocument,
    PartnerRegistrationDocument,
)
from partner.roles import PartnerRole
from project.identifiers import get_eoi_display_identifier
from project.models import EOI, Application, Assessment, EOIAttachment
from review.models import PartnerFlag, PartnerVerification
from common.consts import (
    PARTNER_TYPES,
    CONCERN_CHOICES,
    YEARS_OF_EXP_CHOICES,
    PARTNER_DONORS_CHOICES,
    COLLABORATION_EVIDENCE_MODES,
    FUNCTIONAL_RESPONSIBILITY_CHOICES,
    POLICY_AREA_CHOICES,
    ORG_AUDIT_CHOICES,
    AUDIT_ASSESSMENT_CHOICES,
    JUSTIFICATION_FOR_DIRECT_SELECTION,
    CFEI_TYPES,
    DIRECT_SELECTION_SOURCE,
    BUDGET_CHOICES,
    SELECTION_CRITERIA_CHOICES,
    STAFF_GLOBALLY_CHOICES,
    FINANCIAL_CONTROL_SYSTEM_CHOICES,
    WORKING_LANGUAGES_CHOICES,
)
from common.countries import COUNTRIES_ALPHA2_CODE
from sanctionslist.models import SanctionedNameMatch, SanctionedItem, SanctionedName

COUNTRIES = [x[0] for x in COUNTRIES_ALPHA2_CODE]

filename = os.path.join(settings.PROJECT_ROOT, 'apps', 'common', 'tests', 'test.doc')


fake = Faker()


def get_random_agency():
    return random.choice(AGENCIES).model_instance


def get_random_agency_office():
    return AgencyOffice.objects.order_by("?").first() or AgencyOfficeFactory()


def get_agency_member(agency=None):
    users_queryset = User.objects.filter(agency_members__isnull=False)
    if agency:
        users_queryset = users_queryset.filter(agency_members__office__agency=agency)

    member = users_queryset.order_by("?").first()
    if member:
        return member
    if agency:
        return AgencyMemberFactory(
            office=AgencyOfficeFactory(agency=agency)
        ).user
    else:
        return AgencyMemberFactory().user


def get_partner_member():
    member = User.objects.filter(is_superuser=False, partner_members__isnull=False).order_by("?").first()
    return member or PartnerMemberFactory().user


def get_new_common_file():
    cfile = CommonFile.objects.create()
    cfile.file_field.save('test.csv', open(filename))
    return cfile


def get_cfei_title():
    return f'{fake.catch_phrase()} for {" ".join(generate(4)).title()}'


def get_partner_name():
{'fraction_non_alphanumeric': 0.06879643387815751, 'fraction_numerical': 0.0016344725111441308, 'mean_word_length': 4.9937666963490654, 'pattern_counts': {'":': 0, '<': 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': '399946', 'n_tokens_mistral': 2139, 'n_tokens_neox': 2053, 'n_words': 437}