def stub_lazy_loaded_grouped_loans(array_of_query_and_body, group_level_names):
    stubs = []
    for item in array_of_query_and_body:
        path = "/chunkedGroups"
        query = item['query']
        for group_level_name in group_level_names:
            path += '/' + group_level_name + 's'
            if group_level_name in query:
                path += '/' + str(query[group_level_name])
                del query[group_level_name]
            else:
                break
        stubs.append(StubFactory.make_group_stub(item["body"], path))
    return stubs
def stub_grouped_loans(data):
    loans = []
    for item in data:
        loan = {}
        for key in item:
            loan[key] = item[key]

        path = loan['groupName'].split('-')
        if len(path) == 1:
            loans.append(loan)
        else:
            parent_loan = find_parent(loans, path)
            if not ('children' in parent_loan):
                parent_loan['children'] = []
            parent_loan['children'].append(loan)

    stubs = [StubFactory.make_group_loans_stub(loans)]
    return stubs
def stub_grand_total_row():
    rows = [{"id": "1"}]
    stub = StubFactory.make_group_stub(rows)
    return [stub]
def stub_grouped_loans_by_count(count):
    loans = generate_grouped_loans(int(count))
    stubs = [StubFactory.make_group_loans_stub(loans)]
    return stubs
def stub_loans(count, chunk_size=None, path="/loans"):
    loans = generate_loans(count)
    stub = StubFactory.make_loans_stub(loans, path, chunk_size)
    return [stub]