<commit_before>from collections import namedtuple
from casexml.apps.case.mock import CaseBlock
from casexml.apps.case.xml import V2
from corehq.apps.callcenter.indicator_sets import AAROHI_MOTHER_FORM, CallCenterIndicators, \
    cache_key, CachedIndicators
from corehq.apps.callcenter.utils import sync_user_cases, FakeSyncOp
from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.callcenter.tests.sql_fixture import load_data, load_custom_data, clear_data
from corehq.apps.groups.models import Group
from corehq.apps.hqcase.utils import submit_case_blocks, get_case_by_domain_hq_user_id
from corehq.apps.users.models import CommCareUser
from django.test import TestCase

from django.core import cache

locmem_cache = cache.get_cache('django.core.cache.backends.locmem.LocMemCache')


class FakeSyncOp(object):
    def __init__(self, cases):
        self.actual_owned_cases = cases


def create_domain_and_user(domain_name, username):
    domain = create_domain(domain_name)
    user = CommCareUser.create(domain_name, username, '***')

    domain.call_center_config.enabled = True
    domain.call_center_config.case_owner_id = user.user_id
    domain.call_center_config.case_type = 'cc_flw'
    domain.save()

    sync_user_cases(user)
    return domain, user


def create_cases_for_types(domain, case_types):
    for i, case_type in enumerate(case_types):
        submit_case_blocks(
            CaseBlock(
                create=True,
                case_id='person%s' % i,
                case_type=case_type,
                user_id='user%s' % i,
                version=V2,
            ).as_string(), domain)


def get_indicators(prefix, values, infix=None, is_legacy=False):
    """
    Generate indicators e.g. cases_opened_week0, cases_opened_{case_type}_week0 etc.
    """<commit_msg>Fixed botched merge<commit_after>from collections import namedtuple
from casexml.apps.case.mock import CaseBlock
from casexml.apps.case.xml import V2
from corehq.apps.callcenter.indicator_sets import AAROHI_MOTHER_FORM, CallCenterIndicators, \
    cache_key, CachedIndicators
from corehq.apps.callcenter.utils import sync_user_cases, FakeSyncOp
from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.callcenter.tests.sql_fixture import load_data, load_custom_data, clear_data
from corehq.apps.groups.models import Group
from corehq.apps.hqcase.utils import submit_case_blocks, get_case_by_domain_hq_user_id
from corehq.apps.users.models import CommCareUser
from django.test import TestCase

from django.core import cache

locmem_cache = cache.get_cache('django.core.cache.backends.locmem.LocMemCache')


def create_domain_and_user(domain_name, username):
    domain = create_domain(domain_name)
    user = CommCareUser.create(domain_name, username, '***')

    domain.call_center_config.enabled = True
    domain.call_center_config.case_owner_id = user.user_id
    domain.call_center_config.case_type = 'cc_flw'
    domain.save()

    sync_user_cases(user)
    return domain, user


def create_cases_for_types(domain, case_types):
    for i, case_type in enumerate(case_types):
        submit_case_blocks(
            CaseBlock(
                create=True,
                case_id='person%s' % i,
                case_type=case_type,
                user_id='user%s' % i,
                version=V2,
            ).as_string(), domain)


def get_indicators(prefix, values, infix=None, is_legacy=False):
    """
    Generate indicators e.g. cases_opened_week0, cases_opened_{case_type}_week0 etc.
    """
{'fraction_non_alphanumeric': 0.0829323521086895, 'fraction_numerical': 0.0022643645626945937, 'mean_word_length': 3.9915254237288136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1553995', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1124, 'n_words': 221}