示例#1
0
 def handle(self, **options):
     from google.appengine.ext import testbed
     testbed = testbed.Testbed()
     testbed.activate()
     testbed.init_all_stubs()
     from auto_api import js
     js.model_js()
示例#2
0
def SetUpTestbedTestCase(case):
    """Set up appengine testbed enviroment."""
    case.testbed = testbed.Testbed()

    case.testbed.activate()
    # The oauth_aware decorator will 302 to login unless there is either
    # a current user _or_ a valid oauth header; this is easier to stub.
    case.testbed.setup_env(user_email='*****@*****.**',
                           user_id='1234',
                           overwrite=True)

    case.testbed.init_all_stubs()

    policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
    case.testbed.init_datastore_v3_stub(consistency_policy=policy)
    case.testbed.init_taskqueue_stub(_all_queues_valid=True)

    os.environ['AUTH_DOMAIN'] = 'example.com'

    # Lazily stub out key-fetching RPC dependency.
    def Stub(data, **_):
        return data

    case.patches = [
        mock.patch.object(crypto, 'Decrypt', side_effect=Stub),
        mock.patch.object(crypto, 'Encrypt', side_effect=Stub),
    ]
    for m in case.patches:
        m.start()
示例#3
0
def SetUpTestbedTestCase(case):
  """Set up appengine testbed enviroment."""
  case.testbed = testbed.Testbed()

  case.testbed.activate()
  # The oauth_aware decorator will 302 to login unless there is either
  # a current user _or_ a valid oauth header; this is easier to stub.
  case.testbed.setup_env(
      user_email='*****@*****.**', user_id='1234', overwrite=True)

  case.testbed.init_all_stubs()

  policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
  case.testbed.init_datastore_v3_stub(consistency_policy=policy)
  case.testbed.init_taskqueue_stub(_all_queues_valid=True)

  os.environ['AUTH_DOMAIN'] = 'example.com'

  # Lazily stub out key-fetching RPC dependency.
  crypto.Decrypt = lambda x: x
  crypto.Encrypt = lambda x: x
示例#4
0
import logging
sys.path[:0] = [os.path.dirname(__file__) + "/../vendor"]

from flask import Flask
app = Flask(__name__)

if "APPLICATION_ID" not in os.environ:
    os.environ["APPLICATION_ID"] = "dev~test"

    # Hide all the App Engine cruft.
    logging.disable(logging.INFO)

    from google.appengine.ext import testbed, ndb
    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_all_stubs()
    ndb.get_context().set_cache_policy(False)
    app.testing = True

# Ensure that the Recaptcha field is small.
app.config["RECAPTCHA_DATA_ATTRS"] = {"size": "compact"}

# Enable global CSRF protection.
from flask_wtf.csrf import CsrfProtect
CsrfProtect(app)

# Imported for side effects:
import caravel.storage.config
import caravel.controllers.listings
import caravel.controllers.api
import caravel.controllers.moderation
示例#5
0
import logging
sys.path.append(os.path.dirname(__file__) + "/../vendor")

from flask import Flask
app = Flask(__name__)

if "APPLICATION_ID" not in os.environ:
    os.environ["APPLICATION_ID"] = "dev~test"

    # Hide all the App Engine cruft.
    logging.disable(logging.INFO)

    from google.appengine.ext import testbed, ndb
    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_all_stubs()
    ndb.get_context().set_cache_policy(False)
    app.testing = True

# Ensure that the Recaptcha field is small.
app.config["RECAPTCHA_DATA_ATTRS"] = {"size": "compact"}

# Enable global CSRF protection.
from flask_wtf.csrf import CsrfProtect
CsrfProtect(app)

# Imported for side effects:
import caravel.storage.config
import caravel.controllers.listings
import caravel.controllers.api
import caravel.controllers.moderation
示例#6
0
def init_testbed():
    from google.appengine.ext import testbed
    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_all_stubs()