

def set_parent_case(domain, child_case, parent_case):
    server_modified_on = child_case.server_modified_on
    parent = CaseStructure(case_id=parent_case.case_id)
    CaseFactory(domain).create_or_update_case(CaseStructure(case_id=child_case.case_id, indices=[CaseIndex(related_structure=parent, identifier=INDEX_ID_PARENT, relationship=INDEX_RELATIONSHIP_CHILD)]))
    child_case = CaseAccessors(domain).get_case(child_case.case_id)
    child_case.server_modified_on = server_modified_on
    _save_case(domain, child_case)
    return CaseAccessors(domain).get_case(child_case.case_id)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/data_interfaces/tests/test_auto_case_updates.py set_parent_case/original