示例#1
0
def _test(**kwargs):
    """
        This stub uses the testbed to initialize the bare minimum to use the
        Datastore connector. Tests themselves should setup/tear down their own
        stubs by using DjangaeDiscoverRunner or the nose plugin.

        The stubs here are just for bootstrapping the tests. Obviously any data inserted
        between here, and the tests themselves will be wiped out when the tests begin!
    """

    from google.appengine.ext import testbed
    from google.appengine.datastore import datastore_stub_util

    MINIMAL_STUBS = {
        "init_memcache_stub": {},
        "init_datastore_v3_stub": {
            "use_sqlite": True,
            "auto_id_policy": testbed.AUTO_ID_POLICY_SCATTERED,
            "consistency_policy": datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
        }
    }

    testbed = testbed.Testbed()
    testbed.activate()
    for init_name, stub_kwargs in MINIMAL_STUBS.items():
        getattr(testbed, init_name)(**stub_kwargs)

    yield

    if testbed:
        testbed.deactivate()
示例#2
0
文件: sandbox.py 项目: owad/djangae
def _test(**kwargs):
    """
        This stub uses the testbed to initialize the bare minimum to use the
        Datastore connector. Tests themselves should setup/tear down their own
        stubs by using DjangaeDiscoverRunner or the nose plugin.

        The stubs here are just for bootstrapping the tests. Obviously any data inserted
        between here, and the tests themselves will be wiped out when the tests begin!
    """

    from google.appengine.ext import testbed
    from google.appengine.datastore import datastore_stub_util

    MINIMAL_STUBS = {
        "init_memcache_stub": {},
        "init_datastore_v3_stub": {
            "use_sqlite": True,
            "auto_id_policy": testbed.AUTO_ID_POLICY_SCATTERED,
            "consistency_policy": datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
        }
    }

    testbed = testbed.Testbed()
    testbed.activate()
    for init_name, stub_kwargs in MINIMAL_STUBS.items():
        getattr(testbed, init_name)(**stub_kwargs)

    yield

    if testbed:
        testbed.deactivate()
示例#3
0
def _test(**kwargs):
    """
        This stub uses the testbed to initialize the bare minimum to use the
        Datastore connector. Tests themselves should setup/tear down their own
        stubs by using DjangaeDiscoverRunner or the nose plugin.

        The stubs here are just for bootstrapping the tests. Obviously any data inserted
        between here, and the tests themselves will be wiped out when the tests begin!
    """

    from google.appengine.ext import testbed
    from google.appengine.datastore import datastore_stub_util

    MINIMAL_STUBS = {
        "init_app_identity_stub": {},
        "init_memcache_stub": {},
        "init_datastore_v3_stub": {
            "use_sqlite":
            True,
            "auto_id_policy":
            testbed.AUTO_ID_POLICY_SCATTERED,
            "consistency_policy":
            datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
        }
    }

    from .blobstore_service import start_blobstore_service, stop_blobstore_service

    # Dummy values for testing, based on the defaults for dev_appserver
    # (differentiating between the default runserver port of 8000 can also be useful
    # for picking up hard-coding issues etc.)
    os.environ["HTTP_HOST"] = "localhost:8080"
    os.environ['SERVER_NAME'] = "localhost"
    os.environ['SERVER_PORT'] = "8080"

    os.environ['DEFAULT_VERSION_HOSTNAME'] = '%s:%s' % (
        os.environ['SERVER_NAME'], os.environ['SERVER_PORT'])

    testbed = testbed.Testbed()
    testbed.activate()
    for init_name, stub_kwargs in MINIMAL_STUBS.items():
        getattr(testbed, init_name)(**stub_kwargs)

    start_blobstore_service()
    try:
        yield
    finally:
        stop_blobstore_service()
        if testbed:
            testbed.deactivate()
示例#4
0
def _test(**kwargs):
    """
        This stub uses the testbed to initialize the bare minimum to use the
        Datastore connector. Tests themselves should setup/tear down their own
        stubs by using DjangaeDiscoverRunner or the nose plugin.

        The stubs here are just for bootstrapping the tests. Obviously any data inserted
        between here, and the tests themselves will be wiped out when the tests begin!
    """

    from google.appengine.ext import testbed
    from google.appengine.datastore import datastore_stub_util

    MINIMAL_STUBS = {
        "init_app_identity_stub": {},
        "init_memcache_stub": {},
        "init_datastore_v3_stub": {
            "use_sqlite": True,
            "auto_id_policy": testbed.AUTO_ID_POLICY_SCATTERED,
            "consistency_policy": datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
        }
    }

    from .blobstore_service import start_blobstore_service, stop_blobstore_service

    # Dummy values for testing, based on the defaults for dev_appserver
    # (differentiating between the default runserver port of 8000 can also be useful
    # for picking up hard-coding issues etc.)
    os.environ["HTTP_HOST"] = "localhost:8080"
    os.environ['SERVER_NAME'] = "localhost"
    os.environ['SERVER_PORT'] = "8080"

    os.environ['DEFAULT_VERSION_HOSTNAME'] = '%s:%s' % (
        os.environ['SERVER_NAME'], os.environ['SERVER_PORT']
    )

    testbed = testbed.Testbed()
    testbed.activate()
    for init_name, stub_kwargs in MINIMAL_STUBS.items():
        getattr(testbed, init_name)(**stub_kwargs)

    start_blobstore_service()
    try:
        yield
    finally:
        stop_blobstore_service()
        if testbed:
            testbed.deactivate()
示例#5
0
def TearDownTestbedTestCase(case):
  """Tear down appengine testbed enviroment."""
  case.testbed.deactivate()
示例#6
0
def TearDownTestbedTestCase(case):
    """Tear down appengine testbed enviroment."""
    for m in case.patches:
        m.stop()
    case.testbed.deactivate()