From e0be076399522ad6b6cf9c35c8fc2184b01dd228 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Mon, 17 Aug 2015 11:33:58 -0700 Subject: [PATCH] Adding travis and tox configuration to run the app engine tests --- .travis.yml | 6 ++++++ scripts/install.sh | 4 ++++ tests/data/app.yaml | 10 ++++++++++ tests/test_appengine.py | 4 ++++ tox.ini | 11 ++++++++++- 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/data/app.yaml diff --git a/.travis.yml b/.travis.yml index 46f1cb6..b416272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,12 @@ env: - TOX_ENV=docs - TOX_ENV=system-tests - TOX_ENV=system-tests3 + - TOX_ENV=gae + global: + - GAE_PYTHONPATH=${HOME}/.cache/google_appengine +cache: + directories: + - ${HOME}/.cache install: - ./scripts/install.sh script: diff --git a/scripts/install.sh b/scripts/install.sh index 5e8a17d..0ef7ad2 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -25,3 +25,7 @@ if [[ "${TOX_ENV}" == "pypy" ]]; then pyenv install pypy-2.6.0 pyenv global pypy-2.6.0 fi + +if [[ "${TOX_ENV}" == "gae" && ! -d ${GAE_PYTHONPATH} ]]; then + python scripts/fetch_gae_sdk.py `dirname ${GAE_PYTHONPATH}` +fi diff --git a/tests/data/app.yaml b/tests/data/app.yaml new file mode 100644 index 0000000..9268dfa --- /dev/null +++ b/tests/data/app.yaml @@ -0,0 +1,10 @@ +# Dummy app.yaml to placate nosegae. +application: oauth2client +version: 1 +runtime: python27 +api_version: 1 +threadsafe: yes + +handlers: +- url: /.* + script: null.app diff --git a/tests/test_appengine.py b/tests/test_appengine.py index 2e49a50..b7fcdf1 100644 --- a/tests/test_appengine.py +++ b/tests/test_appengine.py @@ -26,6 +26,7 @@ import datetime import httplib2 import json import os +import tempfile import time import unittest import urllib @@ -58,6 +59,7 @@ from oauth2client.appengine import FlowProperty from oauth2client.appengine import OAuth2Decorator from oauth2client.appengine import OAuth2DecoratorFromClientSecrets from oauth2client.appengine import StorageByKeyName +from oauth2client.client import _CLOUDSDK_CONFIG_ENV_VAR from oauth2client.client import AccessTokenRefreshError from oauth2client.client import Credentials from oauth2client.client import FlowExchangeError @@ -240,8 +242,10 @@ class TestAppAssertionCredentials(unittest.TestCase): self.assertEqual(None, token.expires_in) def test_save_to_well_known_file(self): + os.environ[_CLOUDSDK_CONFIG_ENV_VAR] = tempfile.mkdtemp() credentials = AppAssertionCredentials([]) self.assertRaises(NotImplementedError, save_to_well_known_file, credentials) + del os.environ[_CLOUDSDK_CONFIG_ENV_VAR] class TestFlowModel(db.Model): diff --git a/tox.ini b/tox.ini index 342f512..39fe506 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,py33,py34,pypy,cover +envlist = py26,py27,py33,py34,pypy,gae,cover [testenv] basedeps = keyring @@ -51,6 +51,15 @@ basepython = python2.6 deps = {[testenv]basedeps} django>=1.5,<1.6 +[testenv:gae] +basepython = python2.7 +deps = {[testenv]basedeps} + nosegae +commands = + nosetests --with-gae --gae-application=tests/data --logging-level=INFO {posargs} tests/test_appengine.py +setenv: + PYTHONPATH={env:GAE_PYTHONPATH:} + [testenv:system-tests] basepython = python2.7