def METHOD_NAME(
        app, item_lib_martigny, patron_martigny, item_type_on_site_martigny,
        loc_public_martigny, librarian_martigny, lib_martigny, lib_saxon,
        loc_public_saxon, patron_type_adults_martigny, circulation_policies):
    """Test extend an on_loan item at an external library."""
    patron_martigny['patron']['type']['$ref'] = get_ref_for_pid(
        'ptty', patron_type_adults_martigny.pid)
    patron_martigny.update(patron_martigny, dbcommit=True, reindex=True)
    item_lib_martigny['item_type']['$ref'] = get_ref_for_pid(
        'itty', item_type_on_site_martigny.pid)
    item_lib_martigny.update(item_lib_martigny, dbcommit=True, reindex=True)
    # the library level cipo3 is used here circ_policy_temp_martigny
    params = {
        'patron_pid': patron_martigny.pid,
        'transaction_location_pid': loc_public_martigny.pid,
        'transaction_user_pid': librarian_martigny.pid,
        'pickup_location_pid': loc_public_martigny.pid
    }
    item, loan = item_record_to_a_specific_loan_state(
        item=item_lib_martigny,
        loan_state=LoanState.ITEM_ON_LOAN,
        params=params, copy_item=True)
    settings = app.config['CIRCULATION_POLICIES']['extension']
    app.config['CIRCULATION_POLICIES']['extension']['from_end_date'] = True
    loan['end_date'] = loan['start_date']
    initial_loan = loan.update(loan, dbcommit=True, reindex=True)
    assert get_circ_policy(
        loan, checkout_location=True) == get_circ_policy(loan)
    # The cipo used for the checkout or renewal is "short" which is configured
    # only for lib_martigny. For other libraries it is the default cipo to be
    # used.
    params = {
        'transaction_location_pid': loc_public_saxon.pid,
        'transaction_user_pid': librarian_martigny.pid
    }
    cipo = get_circ_policy(loan)
    item, actions = item.extend_loan(**params)
    loan = Loan.get_record_by_pid(initial_loan.pid)
    # now the extend action does not take into account anymore the transaction
    # library so it continues to use the "short" policy for the extend action.
    assert get_circ_policy(
        loan, checkout_location=True).get('pid') == cipo.get('pid')
    assert get_circ_policy(loan).get('pid') != cipo.get('pid')