# Copyright 2013 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.

import os
import sys

# /appengine/
ROOT_DIR = os.path.dirname(
    os.path.dirname(os.path.realpath(os.path.abspath(__file__))))

_INITIALIZED = False


def setup_test_env(app_id='sample-app'):
  """Sets up App Engine/Django test environment."""
  global _INITIALIZED
  if _INITIALIZED:
    raise Exception('Do not call test_env.setup_test_env() twice.')
  _INITIALIZED = True

  # For depot_tools.
  sys.path.insert(
      0, os.path.join(ROOT_DIR, '..', '..', 'client', 'third_party'))
  # For 'from components import ...' and 'from test_support import ...'.
  sys.path.insert(0, ROOT_DIR)
  sys.path.insert(0, os.path.join(ROOT_DIR, '..', 'third_party_local'))

  from tool_support import gae_sdk_utils
  gae_sdk_utils.setup_gae_env()
  gae_sdk_utils.setup_env(None, app_id, 'v1a', None)

  from components import utils
  utils.fix_protobuf_package()

# Copyright 2013 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.

import os
import sys

# /appengine/
ROOT_DIR = os.path.dirname(
    os.path.dirname(os.path.realpath(os.path.abspath(__file__))))

_INITIALIZED = False


def setup_test_env(app_id='sample-app'):
  """Sets up App Engine test environment."""
  global _INITIALIZED
  if _INITIALIZED:
    raise Exception('Do not call test_env.setup_test_env() twice.')
  _INITIALIZED = True

  # TODO(vadimsh): Remove this once LUCI_PY_USE_GCLOUD is set by default.
  os.environ['LUCI_PY_USE_GCLOUD'] = '1'

  # For depot_tools.
  sys.path.insert(
      0, os.path.join(ROOT_DIR, '..', '..', 'client', 'third_party'))
  # For 'from components import ...' and 'from test_support import ...'.
  sys.path.insert(0, ROOT_DIR)
  sys.path.insert(0, os.path.join(ROOT_DIR, '..', 'third_party_local'))

  from tool_support import gae_sdk_utils
  gae_sdk_utils.setup_gae_env()
  gae_sdk_utils.setup_env(None, app_id, 'v1a', None)

  from components import utils
  utils.fix_protobuf_package()

Switch luci-py tests to use gcloud SDK.
Switch luci-py tests to use gcloud SDK.

R=maruel@chromium.org, iannucci@chromium.org
BUG=835919

Change-Id: Iaf7f361343dfebfc7fd603b8b996ad9fa5412f52
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/1684451
Reviewed-by: Andrii Shyshkalov <a30c74fa30536fe7ea81ed6dec202e35e149e1fd@chromium.org>
Commit-Queue: Vadim Shtayura <9f116ddb1b24f6fc1916a676eb17161b6c07dfc1@chromium.org>
