def configure_client(client, case_name, service_name, use_apps_auth=False):
  # Use a mock HTTP client which will record and replay the HTTP traffic
  # from these tests.
  client.http_client = atom.mock_http_core.MockHttpClient()
  client.http_client.cache_case_name = case_name
  # Getting the auth token only needs to be done once in the course of test
  # runs.
  auth_token_key = '%s_auth_token' % service_name
  if (auth_token_key not in options.values
      and options.get_value('runlive') == 'true'):
    client.http_client.cache_test_name = 'client_login'
    cache_name = client.http_client.get_cache_file_name()
    if options.get_value('clearcache') == 'true':
      client.http_client.delete_session(cache_name)
    client.http_client.use_cached_session(cache_name)
    if not use_apps_auth:
      username = options.get_value('username')
      password = options.get_value('password')
    else:
      username = options.get_value('appsusername')
      password = options.get_value('appspassword')
    auth_token = client.client_login(username, password, case_name,
                                     service=service_name)
    options.values[auth_token_key] = gdata.gauth.token_to_blob(auth_token)
    if client.alt_auth_service is not None:
      options.values[client.alt_auth_service] = gdata.gauth.token_to_blob(
          client.alt_auth_token)
    client.http_client.close_session()
  # Allow a config auth_token of False to prevent the client's auth header
  # from being modified.
  if auth_token_key in options.values:
    client.auth_token = gdata.gauth.token_from_blob(
        options.values[auth_token_key])
  if client.alt_auth_service is not None:
    client.alt_auth_token = gdata.gauth.token_from_blob(
        options.values[client.alt_auth_service])
  if options.get_value('host'):
    client.host = options.get_value('host')
Sets up a mock client which will reuse a saved session.
dataset/ETHPy150Open kuri65536/python-for-android/python3-alpha/python-libs/gdata/test_config.py/configure_client