def test_form_display_condition(self): """ case_id should be renamed in a basic submodule form """ factory = AppFactory(domain=DOMAIN) m0, m0f0 = factory.new_advanced_module('parent', 'gold-fish') factory.form_requires_case(m0f0) # changing this case tag should result in the session var in the submodule entry being updated to match it m0f0.actions.load_update_cases[0].case_tag = 'load_goldfish_renamed' m1, m1f0 = factory.new_advanced_module('child', 'guppy', parent_module=m0) factory.form_requires_case(m1f0, 'gold-fish', update={'question1': '/data/question1'}) factory.form_requires_case(m1f0, 'guppy', parent_case_type='gold-fish') # making this case tag the same as the one in the parent module should mean that it will also get changed # to avoid conflicts m1f0.actions.load_update_cases[1].case_tag = 'load_goldfish_renamed' m1f0.form_filter = "#case/age > 33" XML = """ <partial> <menu id="m1" root="m0"> <text> <locale id="modules.m1"/> </text> <command id="m1-f0" relevant="instance('casedb')/casedb/case[@case_id=instance('commcaresession')/session/data/case_id_load_goldfish_renamed_guppy]/age > 33"/> </menu> </partial> """ self.assertXmlPartialEqual(XML, factory.app.create_suite(), "./menu[@id='m1']")
def test_form_rename_session_vars(self): """ The session vars in the entries for the submodule should match the parent and avoid naming conflicts. """ factory = AppFactory(build_version='2.9') reg_goldfish_mod, reg_goldfish_form = factory.new_basic_module('reg_goldfish', 'gold-fish') factory.form_opens_case(reg_goldfish_form) reg_guppy_mod, reg_guppy_form = factory.new_advanced_module('reg_guppy', 'guppy') factory.form_requires_case(reg_guppy_form, 'gold-fish') factory.form_opens_case(reg_guppy_form, 'guppy', is_subcase=True) upd_goldfish_mod, upd_goldfish_form = factory.new_advanced_module( 'upd_goldfish', 'gold-fish', ) factory.form_requires_case(upd_goldfish_form) # changing this case tag should result in the session var in the submodule entry being updated to match it upd_goldfish_form.actions.load_update_cases[0].case_tag = 'load_goldfish_renamed' upd_guppy_mod, upd_guppy_form = factory.new_advanced_module( 'upd_guppy', 'guppy', parent_module=upd_goldfish_mod, ) upd_guppy_form.source = self.get_xml('original_form', override_path=('data',)) factory.form_requires_case(upd_guppy_form, 'gold-fish', update={'question1': '/data/question1'}) factory.form_requires_case( upd_guppy_form, 'guppy', parent_case_type='gold-fish', update={'question1': '/data/question1'} ) # making this case tag the same as the one in the parent module should mean that it will also get changed # to avoid conflicts upd_guppy_form.actions.load_update_cases[1].case_tag = 'load_goldfish_renamed' self.assertXmlEqual(self.get_xml('child-module-rename-session-vars'), upd_guppy_form.render_xform())