import logging


def get_ctx_options(conf):
  """Gets the appropriate context options for storing test information.

  These context options are passed as keyword arguments to methods including
  ndb.Key.get(), ndb.Key.put(), ndb.get_multi(), and ndb.put_multi() to control
  how various storage methods are used.

  Args:
    conf: The configuration to use.  Its storage specifies how results
        should be stored.

  Returns:
    A dictionary of keyword arguments.
  """
  method = conf.storage
  if method == 'datastore':
    return {}
  if method == 'memcache':
    return {'use_memcache': True, 'use_datastore': False}
  if method == 'immediate':
    return {'use_cache': True, 'use_memcache': False, 'use_datastore': False}
  logging.warning('[aeta] Unknown run method %s.  Falling back to memcache.',
                  method)
  return {'use_memcache': True, 'use_datastore': False}