diff --git a/.travis.yml b/.travis.yml index 46f1cb6f6..b416272cf 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 5e8a17d98..0ef7ad2ba 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 000000000..9268dfa7d --- /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 2e49a5013..b7fcdf15d 100644 --- a/tests/test_appengine.py +++ b/tests/test_appengine.py @@ -26,6 +26,7 @@ import httplib2 import json import os +import tempfile import time import unittest import urllib @@ -58,6 +59,7 @@ 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 @@ def test_get_access_token(self): 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 342f512db..39fe50606 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