Skip to content

Commit

Permalink
Adding gae test session
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Mar 28, 2016
1 parent 055fee1 commit 804b91e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 27 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ env:
- PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/resources/service-account.json
- GOOGLE_CLIENT_SECRETS=${TRAVIS_BUILD_DIR}/testing/resources/client-secrets.json
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine
- GAE_ROOT=${HOME}/.cache/
- secure: Orp9Et2TIwCG/Hf59aa0NUDF1pNcwcS4TFulXX175918cFREOzf/cNZNg+Ui585ZRFjbifZdc858tVuCVd8XlxQPXQgp7bwB7nXs3lby3LYg4+HD83Gaz7KOWxRLWVor6IVn8OxeCzwl6fJkdmffsTTO9csC4yZ7izHr+u7hiO4=
before_install:
Expand Down
96 changes: 70 additions & 26 deletions nox.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
import fnmatch
import os
import tempfile

import nox

REPO_TOOLS_REQ =\
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'

COMMON_PYTEST_ARGS = [
'-x', '--no-success-flaky-report', '--cov', '--cov-config',
'.coveragerc', '--cov-append', '--cov-report=']

SAMPLES = [
'bigquery/api',
'blog/introduction_to_data_models_in_cloud_datastore',
'cloud_logging/api',
'compute/api',
'compute/autoscaler/demo',
'datastore/api',
'managed_vms/cloudsql',
'managed_vms/datastore',
'managed_vms/disk',
'managed_vms/extending_runtime',
'managed_vms/hello_world',
'managed_vms/hello_world_compat',
'managed_vms/memcache',
'managed_vms/pubsub',
'managed_vms/static_files',
'managed_vms/storage',
'monitoring/api',
'storage/api',
]

GAE_SAMPLES = [
'appengine/app_identity/signing',
'appengine/bigquery',
'appengine/blobstore',
'appengine/cloudsql',
'appengine/images',
'appengine/localtesting',
'appengine/logging/reading_logs',
'appengine/logging/writing_logs',
'appengine/mailgun',
'appengine/memcache/guestbook',
'appengine/multitenancy',
'appengine/ndb/modeling',
'appengine/ndb/overview',
'appengine/ndb/transactions',
'appengine/storage',
]


def session_lint(session):
session.install('flake8', 'flake8-import-order')
Expand Down Expand Up @@ -36,32 +80,6 @@ def session_reqcheck(session):
session.run('gcprepotools', command, reqfile)


COMMON_PYTEST_ARGS = [
'-x', '--no-success-flaky-report', '--cov', '--cov-config',
'.coveragerc', '--cov-append', '--cov-report=']

SAMPLES = [
'bigquery/api',
'blog/introduction_to_data_models_in_cloud_datastore',
'cloud_logging/api',
'compute/api',
'compute/autoscaler/demo',
'datastore/api',
'managed_vms/cloudsql',
'managed_vms/datastore',
'managed_vms/disk',
'managed_vms/extending_runtime',
'managed_vms/hello_world',
'managed_vms/hello_world_compat',
'managed_vms/memcache',
'managed_vms/pubsub',
'managed_vms/static_files',
'managed_vms/storage',
'monitoring/api',
'storage/api',
]


@nox.parametrize('interpreter', ['python2.7', 'python3.4'])
def session_tests(session, interpreter, extra_pytest_args=None):
session.interpreter = interpreter
Expand All @@ -77,7 +95,33 @@ def session_tests(session, interpreter, extra_pytest_args=None):
success_codes=[0, 5]) # Treat no test collected as success.


def session_gae(session, extra_pytest_args=None):
session.interpreter = 'python2.7'
session.install(REPO_TOOLS_REQ)
session.install('-r', 'requirements-python2.7-dev.txt')

# Install the app engine sdk and setup import paths.
gae_root = os.environ.get('GAE_ROOT', tempfile.gettempdir())
session.env['PYTHONPATH'] = os.path.join(gae_root, 'google_appengine')
session.run('gcprepotools', 'download-appengine-sdk', gae_root)

# Create a lib directory to prevent the GAE vendor library from
# complaining.
if not os.path.exists('lib'):
os.makedirs('lib')

pytest_args = COMMON_PYTEST_ARGS + (extra_pytest_args or [])

for sample in (session.posargs or GAE_SAMPLES):
session.run(
'py.test', sample,
*pytest_args,
success_codes=[0, 5]) # Treat no test collected as success.


def session_travis(session):
"""On travis, just run with python3.4 and don't run slow or flaky tests."""
session_tests(
session, 'python3.4', extra_pytest_args=['-m not slow and not flaky'])
session_gae(
session, extra_pytest_args=['-m not slow and not flaky'])

0 comments on commit 804b91e

Please sign in to comment.