Beispiel #1
0
 def test_prompt_address_receiver_itemset(self, *args):
     """Setting the appearance to "address"
     """
     self.module.search_config.properties[0].receiver_expression = 'home-street'
     self.module.search_config.properties[0].input_ = 'select1'
     self.module.search_config.properties[0].itemset = Itemset(
         instance_id='states',
         instance_uri="jr://fixture/item-list:states",
         nodeset="instance('states')/state_list/state[@state_name = 'Uttar Pradesh']",
         label='name',
         value='id',
         sort='id',
     )
     suite = self.app.create_suite()
     expected = """
     <partial>
       <prompt key="name" input="select1" receive="home-street">
         <display>
           <text>
             <locale id="search_property.m0.name"/>
           </text>
         </display>
         <itemset nodeset="instance('states')/state_list/state[@state_name = 'Uttar Pradesh']">
           <label ref="name"/>
           <value ref="id"/>
           <sort ref="id"/>
         </itemset>
       </prompt>
     </partial>
     """
     self.assertXmlPartialEqual(expected, suite, "./remote-request[1]/session/query/prompt[@key='name']")
Beispiel #2
0
    def test_prompt_itemset(self):
        self.module.search_config.properties[0].input_ = 'select1'
        self.module.search_config.properties[0].itemset = Itemset(
            instance_id='states',
            instance_uri="jr://fixture/item-list:states",
            nodeset=
            "instance('states')/state_list/state[@state_name = 'Uttar Pradesh']",
            label='name',
            value='id',
            sort='id',
        )
        suite = self.app.create_suite()
        expected = """
        <partial>
          <prompt key="name" input="select1">
            <display>
              <text>
                <locale id="search_property.m0.name"/>
              </text>
            </display>
            <itemset nodeset="instance('states')/state_list/state[@state_name = 'Uttar Pradesh']">
              <label ref="name"/>
              <value ref="id"/>
              <sort ref="id"/>
            </itemset>
          </prompt>
        </partial>
        """
        self.assertXmlPartialEqual(
            expected, suite,
            "./remote-request[1]/session/query/prompt[@key='name']")

        expected_instance = """
        <partial>
          <instance id="states" src="jr://fixture/item-list:states"/>
        </partial>
        """
        self.assertXmlPartialEqual(
            expected_instance,
            suite,
            "./remote-request[1]/instance[@id='states']",
        )
Beispiel #3
0
    def setUp(self):
        self.app = Application.new_app(DOMAIN, "Untitled Application")
        self.app._id = '123'
        self.app.build_spec = BuildSpec(version='2.53.0', build_number=1)
        self.module = self.app.add_module(Module.new_module("Followup", None))
        self.form = self.app.new_form(0, "Untitled Form", None, attachment=get_simple_form("xmlns1.0"))
        self.form.requires = 'case'
        self.module.case_type = 'case'

        self.module.case_details.long.columns.append(
            DetailColumn.wrap(dict(
                header={"en": "name"},
                model="case",
                format="plain",
                field="whatever",
            ))
        )

        self.module.search_config = CaseSearch(
            properties=[
                CaseSearchProperty(name='name', label={'en': 'Name'}),
                CaseSearchProperty(name='favorite_color', label={'en': 'Favorite Color'}, itemset=Itemset(
                    instance_id='item-list:colors', instance_uri='jr://fixture/item-list:colors',
                    nodeset="instance('item-list:colors')/colors_list/colors",
                    label='name', sort='name', value='value'),
                )
            ],
            data_registry="myregistry",
            data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE,
            additional_registry_cases=["'another case ID'"],
        )

        self.reg_module = self.app.add_module(Module.new_module("Registration", None))
        self.reg_form = self.app.new_form(1, "Untitled Form", None, attachment=get_simple_form("xmlns1.0"))
        self.reg_module.case_type = 'case'
        self.reg_form.actions.open_case = OpenCaseAction(
            name_update=ConditionalCaseUpdate(question_path="/data/question1")
        )
        self.reg_form.actions.open_case.condition.type = 'always'
        self.reg_form.post_form_workflow = WORKFLOW_FORM
        self.reg_form.form_links = [
            FormLink(form_id=self.form.get_unique_id())
        ]

        # wrap to have assign_references called
        self.app = Application.wrap(self.app.to_json())
        # reset to newly wrapped module
        self.module = self.app.modules[0]
        self.form = self.module.forms[0]
Beispiel #4
0
    def setUp(self):
        super().setUp()
        self.app = Application.new_app(DOMAIN, "Application with Shadow")
        self.app._id = '456'
        self.app.build_spec = BuildSpec(version='2.53.0', build_number=1)
        self.module = self.app.add_module(Module.new_module("Followup", None))
        self.form = self.app.new_form(0, "Untitled Form", None, attachment=get_simple_form("xmlns1.0"))
        self.form.requires = 'case'
        self.module.case_type = 'case'

        self.module.case_details.long.columns.append(
            DetailColumn.wrap(dict(
                header={"en": "name"},
                model="case",
                format="plain",
                field="whatever",
            ))
        )

        self.module.search_config = CaseSearch(
            properties=[
                CaseSearchProperty(name='name', label={'en': 'Name'}),
                CaseSearchProperty(name='favorite_color', label={'en': 'Favorite Color'}, itemset=Itemset(
                    instance_id='item-list:colors', instance_uri='jr://fixture/item-list:colors',
                    nodeset="instance('item-list:colors')/colors_list/colors",
                    label='name', sort='name', value='value'),
                )
            ],
            data_registry="myregistry",
            data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE,
            additional_registry_cases=["'another case ID'"],
        )

        self.shadow_module = self.app.add_module(ShadowModule.new_module("Shadow", "en"))
        self.shadow_module.source_module_id = self.module.unique_id

        self.shadow_module.case_details.long.columns.append(
            DetailColumn.wrap(dict(
                header={"en": "name"},
                model="case",
                format="plain",
                field="whatever",
            ))
        )

        self.shadow_module.search_config = CaseSearch(
            properties=[
                CaseSearchProperty(name='name', label={'en': 'Name'}),
                CaseSearchProperty(name='favorite_color', label={'en': 'Texture'}, itemset=Itemset(
                    instance_id='item-list:textures', instance_uri='jr://fixture/item-list:textures',
                    nodeset="instance('item-list:textures')/textures_list/textures",
                    label='name', sort='name', value='value'),
                )
            ],
            data_registry="myregistry",
            data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE,
        )

        # wrap to have assign_references called
        self.app = Application.wrap(self.app.to_json())

        # reset to newly wrapped module
        self.module = self.app.modules[0]
        self.shadow_module = self.app.modules[1]