(cases)
return posted_forms, posted_cases
Takes as input a list of unsaved CommCareCase objects

    that don't have any case actions, etc.
    and creates them through the official channel of submitting forms, etc.

    returns a tuple of two lists: forms posted and cases created
Takes as input a list of unsaved CommCareCase objects
Takes as input a list of unsaved CommCareCase objects
def create_real_cases_from_dummy_cases(cases):
    """
    Takes as input a list of unsaved CommCareCase objects

    that don't have any case actions, etc.
    and creates them through the official channel of submitting forms, etc.

    returns a tuple of two lists: forms posted and cases created

    """
    posted_cases = []
    posted_forms = []
    case_blocks_by_domain = defaultdict(list)
    for case in cases:
        if not case.modified_on:
            case.modified_on = datetime.datetime.utcnow()
        if not case._id:
            case._id = uuid.uuid4().hex
        case_blocks_by_domain[case.domain].append(get_case_element(
            case, (CASE_ACTION_CREATE, CASE_ACTION_UPDATE), version='2.0'))
    for domain, case_blocks in case_blocks_by_domain.items():
        form, cases = post_case_blocks(case_blocks, domain=domain)
        posted_forms.append(form)
        posted_cases.extend(cases)
    return posted_forms, posted_cases
def create_real_cases_from_dummy_cases ( cases ) : posted_cases = [ ] posted_forms = [ ] case_blocks_by_domain = defaultdict ( list ) for case in cases : if not case . modified_on : case . modified_on = datetime . datetime . utcnow ( ) if not case . _id : case . _id = uuid . uuid4 ( ) . hex case_blocks_by_domain [ case . domain ] . append ( get_case_element ( case , ( CASE_ACTION_CREATE , CASE_ACTION_UPDATE ) , version = '2.0' ) ) for domain , case_blocks in case_blocks_by_domain . items ( ) : form , cases = post_case_blocks ( case_blocks , domain = domain ) posted_forms . append ( form ) posted_cases . extend ( cases ) return posted_forms , posted_cases