<commit_before>import datetime
from django.test import TestCase

from corehq.apps.app_manager.const import APP_V2
from corehq.apps.app_manager.models import Application
from corehq.apps.data_analytics.malt_generator import MALTTableGenerator
from corehq.apps.data_analytics.models import MALTRow
from corehq.apps.domain.models import Domain
from corehq.apps.users.models import CommCareUser
from corehq.apps.smsforms.app import COMMCONNECT_DEVICE_ID
from corehq.apps.sofabed.models import FormData, MISSING_APP_ID

from dimagi.utils.dates import DateSpan


class MaltGeneratorTest(TestCase):

    DOMAIN_NAME = "test"
    USERNAME = "malt-user"
    DEVICE_ID = "my_phone"
    UNKNOWN_ID = "UNKNOWN_ID"

    correct_date = datetime.datetime.now()
    out_of_range_date = correct_date - datetime.timedelta(days=32)
    malt_month = DateSpan.from_month(correct_date.month, correct_date.year)

    @classmethod
    def setUpClass(cls):
        cls._setup_domain_user()
        cls._setup_apps()
        cls._setup_sofa_forms()
        cls.run_malt_generation()

    @classmethod
    def tearDownClass(cls):
        cls.domain.delete()
        FormData.objects.all().delete()
        MALTRow.objects.all().delete()

    @classmethod
    def _setup_domain_user(cls):
        cls.domain = Domain(name=cls.DOMAIN_NAME)
        cls.domain.save()
        cls.user = CommCareUser.create(cls.DOMAIN_NAME, cls.USERNAME, '*****')
        cls.user.save()
        cls.user_id = cls.user._id

    @classmethod
    def _setup_apps(cls):
        cls.app = Application.new_app(cls.DOMAIN_NAME, "app 1", APP_V2)
        cls.wam_app = Application.new_app(cls.DOMAIN_NAME, "app 2", APP_V2)
        cls.wam_app.amplifies_workers = 'yes'
        cls.app.save()
        cls.wam_app.save()
        cls.app_id = cls.app._id
        cls.wam_app_id = cls.wam_app._id<commit_msg>replace hardcoded val with const<commit_after>import datetime
from django.test import TestCase

from corehq.apps.app_manager.const import APP_V2, AMPLIFIES_YES
from corehq.apps.app_manager.models import Application
from corehq.apps.data_analytics.malt_generator import MALTTableGenerator
from corehq.apps.data_analytics.models import MALTRow
from corehq.apps.domain.models import Domain
from corehq.apps.users.models import CommCareUser
from corehq.apps.smsforms.app import COMMCONNECT_DEVICE_ID
from corehq.apps.sofabed.models import FormData, MISSING_APP_ID

from dimagi.utils.dates import DateSpan


class MaltGeneratorTest(TestCase):

    DOMAIN_NAME = "test"
    USERNAME = "malt-user"
    DEVICE_ID = "my_phone"
    UNKNOWN_ID = "UNKNOWN_ID"

    correct_date = datetime.datetime.now()
    out_of_range_date = correct_date - datetime.timedelta(days=32)
    malt_month = DateSpan.from_month(correct_date.month, correct_date.year)

    @classmethod
    def setUpClass(cls):
        cls._setup_domain_user()
        cls._setup_apps()
        cls._setup_sofa_forms()
        cls.run_malt_generation()

    @classmethod
    def tearDownClass(cls):
        cls.domain.delete()
        FormData.objects.all().delete()
        MALTRow.objects.all().delete()

    @classmethod
    def _setup_domain_user(cls):
        cls.domain = Domain(name=cls.DOMAIN_NAME)
        cls.domain.save()
        cls.user = CommCareUser.create(cls.DOMAIN_NAME, cls.USERNAME, '*****')
        cls.user.save()
        cls.user_id = cls.user._id

    @classmethod
    def _setup_apps(cls):
        cls.app = Application.new_app(cls.DOMAIN_NAME, "app 1", APP_V2)
        cls.wam_app = Application.new_app(cls.DOMAIN_NAME, "app 2", APP_V2)
        cls.wam_app.amplifies_workers = AMPLIFIES_YES
        cls.app.save()
        cls.wam_app.save()
        cls.app_id = cls.app._id
        cls.wam_app_id = cls.wam_app._id
{'fraction_non_alphanumeric': 0.09925093632958802, 'fraction_numerical': 0.003745318352059925, 'mean_word_length': 3.3884976525821595, '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': '1559723', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1275, 'n_words': 218}