<commit_before>import json
import os
from couchdbkit import ResourceNotFound, ResourceConflict
from django.test.testcases import TestCase
from mock import patch
from casexml.apps.case.models import CommCareCase
from corehq.apps.indicators.models import (
    FormLabelIndicatorDefinition,
    FormDataInCaseIndicatorDefinition,
    FormDataAliasIndicatorDefinition,
    CaseDataInFormIndicatorDefinition, IndicatorDefinition)
from mvp_docs.models import IndicatorXForm, IndicatorCase
from mvp_docs.pillows import MVPFormIndicatorPillow, MVPCaseIndicatorPillow
from couchforms.models import XFormInstance
from dimagi.utils.couch.database import get_db

INDICATOR_TEST_DOMAIN = 'indicator-domain'
INDICATOR_TEST_NAMESPACE = 'indicator_test'


class IndicatorPillowTests(TestCase):

    @classmethod
    def setUpClass(cls):
        try:
            get_db().delete_doc('INDICATOR_CONFIGURATION')
        except ResourceNotFound:
            pass
        get_db().save_doc({
            '_id': 'INDICATOR_CONFIGURATION',
            'namespaces': {
                INDICATOR_TEST_DOMAIN: [
                    [
                        INDICATOR_TEST_NAMESPACE,
                        "INDICATOR TEST Namespace",
                    ],
                ],
            }
        })
        cls.form_pillow = MVPFormIndicatorPillow()
        cls.case_pillow = MVPCaseIndicatorPillow()

    def setUp(self):
        # memoization across tests can break things
        IndicatorDefinition.get_all.reset_cache()

    def _save_doc_to_db(self, docname, doc_class):
        doc_dict = _get_doc_data(docname)
        try:
            doc_instance = doc_class.wrap(doc_dict)
            doc_instance.save()
        except ResourceConflict:
            doc_instance = doc_class.get(doc_dict['_id'])
            doc_instance._doc.update(doc_dict)<commit_msg>delete indicator doc after tests<commit_after>import json
import os
from couchdbkit import ResourceNotFound, ResourceConflict
from django.test.testcases import TestCase
from mock import patch
from casexml.apps.case.models import CommCareCase
from corehq.apps.indicators.models import (
    FormLabelIndicatorDefinition,
    FormDataInCaseIndicatorDefinition,
    FormDataAliasIndicatorDefinition,
    CaseDataInFormIndicatorDefinition, IndicatorDefinition)
from mvp_docs.models import IndicatorXForm, IndicatorCase
from mvp_docs.pillows import MVPFormIndicatorPillow, MVPCaseIndicatorPillow
from couchforms.models import XFormInstance
from dimagi.utils.couch.database import get_db

INDICATOR_TEST_DOMAIN = 'indicator-domain'
INDICATOR_TEST_NAMESPACE = 'indicator_test'


class IndicatorPillowTests(TestCase):

    @classmethod
    def setUpClass(cls):
        try:
            get_db().delete_doc('INDICATOR_CONFIGURATION')
        except ResourceNotFound:
            pass
        get_db().save_doc({
            '_id': 'INDICATOR_CONFIGURATION',
            'namespaces': {
                INDICATOR_TEST_DOMAIN: [
                    [
                        INDICATOR_TEST_NAMESPACE,
                        "INDICATOR TEST Namespace",
                    ],
                ],
            }
        })
        cls.form_pillow = MVPFormIndicatorPillow()
        cls.case_pillow = MVPCaseIndicatorPillow()

    def setUp(self):
        # memoization across tests can break things
        IndicatorDefinition.get_all.reset_cache()

    @classmethod
    def tearDownClass(cls):
        get_db().delete_doc('INDICATOR_CONFIGURATION')

    def _save_doc_to_db(self, docname, doc_class):
        doc_dict = _get_doc_data(docname)
        try:
            doc_instance = doc_class.wrap(doc_dict)
            doc_instance.save()
        except ResourceConflict:
            doc_instance = doc_class.get(doc_dict['_id'])
            doc_instance._doc.update(doc_dict)
{'fraction_non_alphanumeric': 0.06748949579831932, 'fraction_numerical': 0.0, 'mean_word_length': 2.7601184600197435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5441873', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1081, 'n_words': 203}