Пример #1
0
 def test_advanced_suite_load_case_from_fixture_with_custom_fixture(self):
     app = Application.wrap(self.get_json('suite-advanced'))
     app.get_module(1).get_form(0).actions.load_update_cases.append(
         LoadUpdateAction(
             case_tag="adherence",
             case_type="clinic",
             load_case_from_fixture=LoadCaseFromFixture(
                 fixture_nodeset=
                 "instance('enikshay:calendar')/calendar/year/month/day[@date > 735992 and @date < 736000]",
                 fixture_tag="selected_date",
                 fixture_variable="date",
                 case_property="adherence_event_date",
                 auto_select=True,
             )))
     with patch(
             'corehq.apps.app_manager.suite_xml.post_process.instances.toggles.CUSTOM_CALENDAR_FIXTURE.enabled'
     ) as mock_toggle:
         mock_toggle.return_value = True
         suite = app.create_suite()
     self.assertXmlPartialEqual(
         self.get_xml('load_case_from_custom_fixture_session'), suite,
         './entry[2]/session')
     self.assertXmlPartialEqual(
         self.get_xml('load_case_from_custom_fixture_instance'), suite,
         './entry[2]/instance')
Пример #2
0
 def test_with_computed(self):
     self.form.session_endpoint_id = 'my_form'
     self.form.function_datum_endpoints = ["extra_id"]
     self.factory.form_requires_case(self.form,
                                     case_type=self.parent_case_type)
     self.form.actions.load_update_cases.append(
         LoadUpdateAction(
             case_tag="adherence",
             case_type=self.parent_case_type,
             load_case_from_fixture=LoadCaseFromFixture(
                 fixture_nodeset=
                 "instance('item-list:table_tag')/calendar/year]",
                 fixture_tag="selected_date",
                 fixture_variable="./@date",
                 case_property="adherence_event_date",
                 auto_select=True,
                 arbitrary_datum_id="extra_id",
                 arbitrary_datum_function="extra_function()",
             )))
     with patch(
             'corehq.util.view_utils.get_url_base') as get_url_base_patch:
         get_url_base_patch.return_value = 'https://www.example.com'
         suite = self.factory.app.create_suite()
     self.assertXmlPartialEqual(
         """
         <partial>
             <endpoint id="my_form">
                 <argument id="case_id_load_mother_0"/>
                 <argument id="extra_id"/>
                 <argument id="selected_date"/>
                 <argument id="adherence"/>
                 <stack>
                     <push>
                       <datum id="case_id_load_mother_0" value="$case_id_load_mother_0"/>
                       <command value="'claim_command.my_form.case_id_load_mother_0'"/>
                     </push>
                     <push>
                       <datum id="selected_date" value="$selected_date"/>
                       <command value="'claim_command.my_form.selected_date'"/>
                     </push>
                     <push>
                       <datum id="adherence" value="$adherence"/>
                       <command value="'claim_command.my_form.adherence'"/>
                     </push>
                     <push>
                         <command value="'m0'"/>
                         <datum id="case_id_load_mother_0" value="$case_id_load_mother_0"/>
                         <datum id="extra_id" value="$extra_id"/>
                         <datum id="selected_date" value="$selected_date"/>
                         <datum id="adherence" value="$adherence"/>
                         <command value="'m0-f0'"/>
                     </push>
                 </stack>
             </endpoint>
         </partial>
         """,
         suite,
         "./endpoint",
     )
 def test_advanced_suite_load_case_from_fixture_with_report_fixture(self):
     app = Application.wrap(self.get_json('suite-advanced'))
     app.get_module(1).get_form(0).actions.load_update_cases.append(LoadUpdateAction(
         case_tag="",
         case_type="clinic",
         load_case_from_fixture=LoadCaseFromFixture(
             fixture_nodeset="instance('commcare:reports')/reports/report[@id='some-report-guid']/rows/row",
             fixture_tag="selected_row",
             fixture_variable="index",
         )
     ))
     suite = app.create_suite()
     self.assertXmlPartialEqual(self.get_xml('load_case_from_report_fixture_session'), suite, './entry[2]/session')
     self.assertXmlPartialEqual(self.get_xml('load_case_from_report_fixture_instance'), suite, './entry[2]/instance')
 def test_advanced_suite_load_from_fixture(self):
     nodeset = "instance('item-list:table_tag')/calendar/year/month/day[@date > 735992 and @date < 736000]"
     app = Application.wrap(self.get_json('suite-advanced'))
     app.get_module(1).get_form(0).actions.load_update_cases.append(LoadUpdateAction(
         case_type="clinic",
         load_case_from_fixture=LoadCaseFromFixture(
             fixture_nodeset=nodeset,
             fixture_tag="selected_date",
             fixture_variable="date",
             case_property="adherence_event_date",
             auto_select=True,
         )
     ))
     suite = app.create_suite()
     self.assertXmlPartialEqual(self.get_xml('load_from_fixture_session'), suite, './entry[2]/session')
     self.assertXmlPartialEqual(self.get_xml('load_from_fixture_instance'), suite, './entry[2]/instance')