def _delete_child_index(self): ref = CaseStructure() ref.case_id = "" # reset case_id to empty self.factory.create_or_update_case( CaseStructure(case_id=self.child.case_id, indices=[CaseIndex(ref, related_type='parent')], walk_related=False), ) # re-fetch case to clear memoized properties accessors = CaseAccessors(self.parent.domain) self.parent = accessors.get_case(self.parent.case_id) self.child = accessors.get_case(self.child.case_id)
def test_deleted_index(self): hierarchy = self.test_normal_index() parent, child = hierarchy['case_list'] factory = CaseFactory() ref = CaseStructure() ref.case_id = "" # reset case_id to empty factory.create_or_update_case( CaseStructure(case_id=child.case_id, indices=[CaseIndex(ref, related_type='parent')], walk_related=False), ) # re-fetch case to clear memoized properties parent = CommCareCase.objects.get_case(parent.case_id, parent.domain) hierarchy = get_case_hierarchy(parent, {}) self.assertEqual(1, len(hierarchy['case_list'])) self.assertEqual(0, len(hierarchy['child_cases']))