'Helper method for testing whether or not group_id was passed to the user_profile request.'

def _test_group_id_passed_to_user_profile(self, mock_request, expect_group_id_in_request, requesting_user, profiled_user, group_id, pass_group_id):

    def get_params_from_user_info_call(for_specific_course):
        "\n                                                Returns    the    request    parameters    for    the    user    info    call    with    either    course_id    specified    or    not,\n                                                depending    on    value    of    'for_specific_course'.\n                                                "
        for r_call in mock_request.call_args_list:
            if (not r_call[0][1].endswith(self.cs_endpoint)):
                params = r_call[1]['params']
                has_course_id = ('course_id' in params)
                if ((for_specific_course and has_course_id) or ((not for_specific_course) and (not has_course_id))):
                    return params
        self.assertTrue(False, ("Did    not    find    appropriate    user_profile    call    for    'for_specific_course'=" + for_specific_course))
    mock_request.reset_mock()
    self.call_view_for_profiled_user(mock_request, requesting_user, profiled_user, group_id, pass_group_id=pass_group_id, is_ajax=False)
    params_without_course_id = get_params_from_user_info_call(False)
    self.assertNotIn('group_id', params_without_course_id)
    params_with_course_id = get_params_from_user_info_call(True)
    if expect_group_id_in_request:
        self.assertIn('group_id', params_with_course_id)
        self.assertEqual(group_id, params_with_course_id['group_id'])
    else:
        self.assertNotIn('group_id', params_with_course_id)
