def get_test_app(self): app = Application.new_app('domain', 'New App') app.version = 1 m0 = self._make_module(app, 0, 'parent') m0.get_form(0).actions.subcases.append( OpenSubCaseAction(case_type='child', reference_id='parent')) m1 = self._make_module(app, 1, 'child') m1.get_form(0).actions.subcases.append( OpenSubCaseAction(case_type='grand child', reference_id='parent')) m2 = self._make_module(app, 2, 'grand child') m3 = app.add_module(AdvancedModule.new_module('Module3', lang='en')) m3.case_type = 'other grand child' m3f0 = m3.new_form('other form', 'en') m3f0.actions.load_update_cases.append( LoadUpdateAction(case_type='child', case_tag='child')) m3f0.actions.open_cases.append( AdvancedOpenCaseAction(name_path='/data/question1', case_type='other grand child', case_indices=[CaseIndex(tag='child')])) m3f0.actions.open_cases[0].open_condition.type = 'always' m2.parent_select = ParentSelect(active=True, module_id=m1.unique_id) m1.parent_select = ParentSelect(active=True, module_id=m0.unique_id) expected_hierarchy = { 'parent': { 'child': { 'grand child': {}, 'other grand child': {} } } } return app, expected_hierarchy
def get_test_app(self): app = Application.new_app('domain', 'New App') app._id = uuid.uuid4().hex app.version = 1 m0 = self._make_module(app, 0, 'parent') m0.get_form(0).actions.subcases.extend([ OpenSubCaseAction(case_type='child', reference_id='parent'), OpenSubCaseAction(case_type='other_child', reference_id='parent') ]) m1 = self._make_module(app, 1, 'child') m1.get_form(0).actions.subcases.append( OpenSubCaseAction(case_type='grand child', reference_id='parent')) m2 = self._make_module(app, 2, 'grand child') m3 = app.add_module(AdvancedModule.new_module('Module3', lang='en')) m3.case_type = 'other grand child' m3f0 = m3.new_form('other form', 'en') m3f0.actions.load_update_cases.append( LoadUpdateAction(case_type='child', case_tag='child')) m3f0.actions.open_cases.append( AdvancedOpenCaseAction( name_path='/data/question1', case_type='other grand child', case_indices=[CaseIndex(tag='child', reference_id='father')])) m3f0.actions.open_cases[0].open_condition.type = 'always' m4 = app.add_module(AdvancedModule.new_module('Module4', lang='en')) m4.case_type = 'extension' self._make_module(app, 5, 'other_child') m4f0 = m4.new_form('other form', 'en') m4f0.actions.load_update_cases.extend([ LoadUpdateAction(case_type='child', case_tag='child'), LoadUpdateAction(case_type='other_child', case_tag='other_child'), ]) m4f0.actions.open_cases.extend([ AdvancedOpenCaseAction(name_path='/data/question1', case_type='extension', case_indices=[ CaseIndex(tag='child', relationship='extension', reference_id='host') ]), AdvancedOpenCaseAction( # 'extension' case has 2 parents name_path='/data/question1', case_type='extension', case_indices=[ CaseIndex(tag='other_child', relationship='extension', reference_id='host') ]) ]) m4f0.actions.open_cases[0].open_condition.type = 'always' m4f0.actions.open_cases[1].open_condition.type = 'always' m2.parent_select = ParentSelect(active=True, module_id=m1.unique_id) m1.parent_select = ParentSelect(active=True, module_id=m0.unique_id) return app
def test_child_module_with_parent_select_entry_datums(self): """ m0 - opens 'gold-fish' case. m1 - has m0 as root-module, has parent-select, updates 'guppy' case, creates 'pregnancy' subcases to guppy """ self.module_1.root_module_id = self.module_0.unique_id # m0f0 registers gold-fish case self.module_0.case_type = 'gold-fish' m0f0 = self.module_0.get_form(0) m0f0.requires = 'case' m0f0.actions.update_case = UpdateCaseAction( update={'question2': '/data/question2'}) m0f0.actions.update_case.condition.type = 'always' # m1f0 has parent-select, updates `guppy` case, and opens sub-subcase 'pregnancy' self.module_1.case_type = 'guppy' self.module_1.parent_select = ParentSelect( active=True, module_id=self.module_0.unique_id) m1f0 = self.module_1.get_form(0) m1f0.requires = 'case' m1f0.actions.update_case = UpdateCaseAction( update={'question2': '/data/question2'}) m1f0.actions.update_case.condition.type = 'always' m1f0.actions.subcases.append( OpenSubCaseAction(case_type='pregnancy', case_name="/data/question1", condition=FormActionCondition(type='always'))) self.assertXmlPartialEqual( self.get_xml('child-module-with-parent-select-entry-datums-added'), self.app.create_suite(), "./entry")
def setUp(self): factory = AppFactory(DOMAIN, "App with DR and child modules", build_version='2.53.0') m0, f0 = factory.new_basic_module("case list", "case") factory.form_requires_case(f0) m1, f1 = factory.new_basic_module("child case list", "case", parent_module=m0) m1.parent_select = ParentSelect(active=True, relationship="other", module_id=m0.get_or_create_unique_id()) f2 = factory.new_form(m1) factory.form_requires_case(f1) factory.form_requires_case(f2) m1.search_config = CaseSearch( properties=[CaseSearchProperty(name='name', label={'en': 'Name'})], data_registry="myregistry", data_registry_workflow=REGISTRY_WORKFLOW_LOAD_CASE, ) # link from f1 to f2 (both in the child module) f1.post_form_workflow = WORKFLOW_FORM f1.form_links = [FormLink(form_id=f2.get_unique_id())] factory.app._id = "123" # wrap to have assign_references called self.app = Application.wrap(factory.app.to_json())