Example #1
0
def init_datastore():
    from google.appengine.ext import testbed
    from google.appengine.ext import ndb

    # First, create an instance of the Testbed class.
    testbed = testbed.Testbed()
    # Then activate the testbed, which prepares the service stubs for use.
    testbed.activate()
    # Next, declare which service stubs you want to use.
    testbed.init_app_identity_stub()
    testbed.init_datastore_v3_stub()
    testbed.init_memcache_stub()
    testbed.init_blobstore_stub()
    testbed.init_urlfetch_stub()
    # Clear ndb's in-context cache between tests.
    # This prevents data from leaking between tests.
    # Alternatively, you could disable caching by
    # using ndb.get_context().set_cache_policy(False)
    ndb.get_context().clear_cache()
Example #2
0
def main(sdk_path, test_path):
    # If the sdk path points to a google cloud sdk installation
    # then we should alter it to point to the GAE platform location.
    if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
        sys.path.insert(0, os.path.join(sdk_path, 'platform/google_appengine'))
    else:
        sys.path.insert(0, sdk_path)

    # Ensure that the google.appengine.* packages are available
    # in tests as well as all bundled third-party packages.
    import dev_appserver
    dev_appserver.fix_sys_path()

    # Loading appengine_config from the current project ensures that any
    # changes to configuration there are available to all tests (e.g.
    # sys.path modifications, namespaces, etc.)
    try:
        import appengine_config
        (appengine_config)
    except ImportError:
        print "Note: unable to import appengine_config."

    from google.appengine.ext import testbed

    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_app_identity_stub()
    testbed.init_datastore_v3_stub()
    testbed.init_user_stub()
    testbed.init_memcache_stub()

    # Discover and run tests.
    suite = unittest.loader.TestLoader().discover(test_path)

    for root, dirs, files in os.walk(test_path):
        for name in dirs:
            # print(os.path.join(root,name))
            suite.addTests(unittest.loader.TestLoader().discover(
                os.path.join(root, name)))

    unittest.TextTestRunner(verbosity=2).run(suite)
Example #3
0
def main(sdk_path, test_path):
    # If the sdk path points to a google cloud sdk installation
    # then we should alter it to point to the GAE platform location.
    if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
        sys.path.insert(0, os.path.join(sdk_path, 'platform/google_appengine'))
    else:
        sys.path.insert(0, sdk_path)

    # Ensure that the google.appengine.* packages are available
    # in tests as well as all bundled third-party packages.
    import dev_appserver
    dev_appserver.fix_sys_path()

    # Loading appengine_config from the current project ensures that any
    # changes to configuration there are available to all tests (e.g.
    # sys.path modifications, namespaces, etc.)
    try:
        import appengine_config
        (appengine_config)
    except ImportError:
        print "Note: unable to import appengine_config."

    from google.appengine.ext import testbed

    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_app_identity_stub()
    testbed.init_datastore_v3_stub()
    testbed.init_user_stub()
    testbed.init_memcache_stub()

    # Discover and run tests.
    suite = unittest.loader.TestLoader().discover(test_path)

    for root, dirs, files in os.walk(test_path):
        for name in dirs:
            # print(os.path.join(root,name))
            suite.addTests(unittest.loader.TestLoader().discover(os.path.join(root,name)))

    unittest.TextTestRunner(verbosity=2).run(suite)
Example #4
0
sys.path.insert(0, '/home/jonparrott/bin/google_appengine')

# # for OSX default
# if os.uname() == 'Darwin':
sys.path.insert(0, '/usr/local/google_appengine')


import google
reload(google)  # Remove wrong module
import dev_appserver
dev_appserver.fix_sys_path()

from google.appengine.ext import testbed
testbed = testbed.Testbed()
testbed.activate()
testbed.init_memcache_stub()

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.viewcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'
Example #5
0
import dev_appserver  # noqa
sys.path.extend(dev_appserver.EXTRA_PATHS)

from google.appengine.ext import testbed  # noqa

testbed = testbed.Testbed()
testbed.activate()

# If you have PIL installed, you can just use:
# testbed.init_all_stubs()

# If you don't have PIL installed, you have to manually deselect the
# images_stub and init the rest. You may be able to speed
# things up by only selecting the ones you need and commenting the rest.

# testbed.init_images_stub()
testbed.init_app_identity_stub()
testbed.init_blobstore_stub()
testbed.init_capability_stub()
testbed.init_channel_stub()
testbed.init_datastore_v3_stub()
testbed.init_files_stub()
testbed.init_logservice_stub()
testbed.init_mail_stub()
testbed.init_memcache_stub()
testbed.init_taskqueue_stub()
testbed.init_urlfetch_stub()
testbed.init_user_stub()
testbed.init_xmpp_stub()