<commit_before>from django.test import SimpleTestCase

from corehq.apps.app_manager.models import (
    Application,
    ConditionalCaseUpdate,
    Module,
    PreloadAction,
    UpdateCaseAction,
)
from corehq.apps.app_manager.tests.util import (
    SuiteMixin,
    TestXmlMixin,
    patch_get_xform_resource_overrides,
)


@patch_get_xform_resource_overrides()
class SuiteUsercaseTest(SimpleTestCase, SuiteMixin):
    file_path = ('data', 'suite')

    def test_usercase_id_added_update(self, *args):
        app = Application.new_app('domain', "Untitled Application")

        child_module = app.add_module(Module.new_module("Untitled Module", None))
        child_module.case_type = 'child'

        child_form = app.new_form(0, "Untitled Form", None)
        child_form.xmlns = 'http://id_m1-f0'
        child_form.requires = 'case'
        child_form.actions.usercase_update = UpdateCaseAction(
            update={'name': ConditionalCaseUpdate(question_path='/data/question1')})
        child_form.actions.usercase_update.condition.type = 'always'

        self.assertXmlPartialEqual(self.get_xml('usercase_entry'), app.create_suite(), "./entry[1]")

    def test_usercase_id_added_preload(self, *args):
        app = Application.new_app('domain', "Untitled Application")

        child_module = app.add_module(Module.new_module("Untitled Module", None))
        child_module.case_type = 'child'

        child_form = app.new_form(0, "Untitled Form", None)
        child_form.xmlns = 'http://id_m1-f0'
        child_form.requires = 'case'
        child_form.actions.usercase_preload = PreloadAction(preload={'/data/question1': 'name'})
        child_form.actions.usercase_preload.condition.type = 'always'
<commit_msg>rename vars for clarity<commit_after>from django.test import SimpleTestCase

from corehq.apps.app_manager.models import (
    Application,
    ConditionalCaseUpdate,
    Module,
    PreloadAction,
    UpdateCaseAction,
)
from corehq.apps.app_manager.tests.util import (
    SuiteMixin,
    TestXmlMixin,
    patch_get_xform_resource_overrides,
)


@patch_get_xform_resource_overrides()
class SuiteUsercaseTest(SimpleTestCase, SuiteMixin):
    file_path = ('data', 'suite')

    def test_usercase_id_added_update(self, *args):
        app = Application.new_app('domain', "Untitled Application")

        module = app.add_module(Module.new_module("Untitled Module", None))
        module.case_type = 'child'

        form = app.new_form(0, "Untitled Form", None)
        form.xmlns = 'http://id_m1-f0'
        form.requires = 'case'
        form.actions.usercase_update = UpdateCaseAction(
            update={'name': ConditionalCaseUpdate(question_path='/data/question1')})
        form.actions.usercase_update.condition.type = 'always'

        self.assertXmlPartialEqual(self.get_xml('usercase_entry'), app.create_suite(), "./entry[1]")

    def test_usercase_id_added_preload(self, *args):
        app = Application.new_app('domain', "Untitled Application")

        module = app.add_module(Module.new_module("Untitled Module", None))
        module.case_type = 'child'

        form = app.new_form(0, "Untitled Form", None)
        form.xmlns = 'http://id_m1-f0'
        form.requires = 'case'
        form.actions.usercase_preload = PreloadAction(preload={'/data/question1': 'name'})
        form.actions.usercase_preload.condition.type = 'always'

{'fraction_non_alphanumeric': 0.11841326228537596, 'fraction_numerical': 0.0053285968028419185, 'mean_word_length': 3.7324929971988796, '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': '7482216', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1078, 'n_words': 169}