Skip to content

Commit

Permalink
Merge pull request #185 from GoogleCloudPlatform/pytest
Browse files Browse the repository at this point in the history
Moving to py.test test runner
  • Loading branch information
Jon Wayne Parrott committed Feb 18, 2016
2 parents 886fa25 + d9ce5d1 commit 95d112e
Show file tree
Hide file tree
Showing 125 changed files with 299 additions and 230 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ lib
testing/resources/test-env.sh
testing/resources/service-account.json
secrets.tar
.cache
junit.xml
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ before_install:
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d
- tar xvf secrets.tar
install:
- pip install tox
- pip install tox coverage
- pip install -e git+https://github.com/GoogleCloudPlatform/python-repo-tools#egg=python-repo-tools
- gcp-python-repo-tools download-appengine-sdk `dirname "${GAE_PYTHONPATH}"`
script:
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh
- tox
- coverage report
Empty file removed appengine/__init__.py
Empty file.
Empty file removed appengine/app_identity/__init__.py
Empty file.
Empty file.
3 changes: 1 addition & 2 deletions appengine/app_identity/signing/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest
import webtest

from . import main


class TestAppIdentityHandler(AppEngineTest):
def setUp(self):
Expand Down
Empty file removed appengine/bigquery/__init__.py
Empty file.
1 change: 1 addition & 0 deletions appengine/bigquery/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START all]

"""
Expand Down
3 changes: 1 addition & 2 deletions appengine/bigquery/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
import re

from apiclient.http import HttpMock
import main
import mock
import testing
import webtest

from . import main


class TestAuthSample(testing.AppEngineTest):

Expand Down
Empty file removed appengine/blobstore/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/blobstore/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
import testing
import webtest

from . import main


class TestBlobstoreSample(testing.AppEngineTest):

Expand Down
Empty file removed appengine/cloudsql/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/cloudsql/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import re
from unittest.case import SkipTest

import main
import testing
import webtest

from . import main


class TestMySQLSample(testing.AppEngineTest):

Expand Down
9 changes: 9 additions & 0 deletions appengine/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import testing.appengine


def pytest_configure(config):
testing.appengine.setup_sdk_imports()


def pytest_runtest_call(item):
testing.appengine.import_appengine_config()
Empty file removed appengine/i18n/__init__.py
Empty file.
Empty file removed appengine/images/__init__.py
Empty file.
11 changes: 3 additions & 8 deletions appengine/images/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
import mock
from testing import AppEngineTest
import webtest

from . import main


class TestHandlers(AppEngineTest):
def setUp(self):
super(TestHandlers, self).setUp()

# Workaround for other tests clobbering our Greeting model.
reload(main)

self.app = webtest.TestApp(main.app)

def test_get(self):
Expand All @@ -40,7 +35,7 @@ def test_get(self):
# Let's check if the response is correct.
self.assertEqual(response.status_int, 200)

@mock.patch('appengine.images.main.images')
@mock.patch('main.images')
def test_post(self, mock_images):
mock_images.resize.return_value = 'asdf'

Expand Down Expand Up @@ -68,7 +63,7 @@ def test_img_missing(self):
# Bogus image id, should get error
self.app.get('/img?img_id=123', status=500)

@mock.patch('appengine.images.main.images')
@mock.patch('main.images')
def test_post_and_get(self, mock_images):
mock_images.resize.return_value = 'asdf'

Expand Down
Empty file removed appengine/localtesting/__init__.py
Empty file.
Empty file removed appengine/logging/__init__.py
Empty file.
Empty file.
3 changes: 1 addition & 2 deletions appengine/logging/reading_logs/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest
import webtest

from . import main


class TestReadingLogs(AppEngineTest):
def setUp(self):
Expand Down
Empty file.
3 changes: 1 addition & 2 deletions appengine/logging/writing_logs/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest
import webtest

from . import main


class TestWritingLogs(AppEngineTest):
def setUp(self):
Expand Down
Empty file removed appengine/mailgun/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/mailgun/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest, Http2Mock
import webtest

from . import main


class TestMailgunHandlers(AppEngineTest):
def setUp(self):
Expand Down
Empty file removed appengine/memcache/__init__.py
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions appengine/memcache/guestbook/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import main
from testing import AppEngineTest
import webtest

from . import main


class TestHandlers(AppEngineTest):

Expand Down
Empty file removed appengine/multitenancy/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/multitenancy/datastore_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datastore
import testing
import webtest

from . import datastore


class TestNamespaceDatastoreSample(testing.AppEngineTest):

Expand Down
3 changes: 1 addition & 2 deletions appengine/multitenancy/memcache_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import memcache
import testing
import webtest

from . import memcache


class TestNamespaceMemcacheSample(testing.AppEngineTest):

Expand Down
3 changes: 1 addition & 2 deletions appengine/multitenancy/taskqueue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import taskqueue
import testing
import webtest

from . import taskqueue


class TestNamespaceTaskQueueSample(testing.AppEngineTest):

Expand Down
Empty file removed appengine/ndb/__init__.py
Empty file.
Empty file removed appengine/ndb/modeling/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/contact_with_group_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

"""Test classes for code snippet for modeling article."""

import contact_with_group_models as models
from google.appengine.ext import ndb
from testing import AppEngineTest

from . import contact_with_group_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the Contact model with groups."""
Expand Down
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/keyproperty_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

import unittest

import keyproperty_models as models
from testing import AppEngineTest

from . import keyproperty_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the Contact model class with KeyProperty."""
Expand Down
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/naive_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

"""Test classes for code snippet for modeling article."""

import naive_models as models
from testing import AppEngineTest

from . import naive_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the naive Contact model classe."""
Expand Down
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/parent_child_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"""Test classes for code snippet for modeling article."""

from google.appengine.ext import ndb
import parent_child_models as models
from testing import AppEngineTest

from . import parent_child_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the Contact model class with KeyProperty."""
Expand Down
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/relation_model_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"""Test classes for code snippet for modeling article."""

from google.appengine.ext import ndb
import relation_model_models as models
from testing import AppEngineTest

from . import relation_model_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the Contact model with relationship model."""
Expand Down
3 changes: 1 addition & 2 deletions appengine/ndb/modeling/structured_property_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

"""Test classes for code snippet for modeling article."""

import structured_property_models as models
from testing import AppEngineTest

from . import structured_property_models as models


class ContactTestCase(AppEngineTest):
"""A test case for the Contact model with StructuredProperty."""
Expand Down
Empty file removed appengine/ndb/overview/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/ndb/overview/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest
import webtest

from . import main


class TestHandlers(AppEngineTest):
def test_hello(self):
Expand Down
Empty file.
3 changes: 1 addition & 2 deletions appengine/ndb/transactions/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
from testing import AppEngineTest

from . import main


class TestHandlers(AppEngineTest):
def setUp(self):
Expand Down
Empty file removed appengine/storage/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions appengine/storage/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# limitations under the License.
import re

import main
import testing
import webtest

from . import main


class TestStorageSample(testing.AppEngineTest):

Expand Down
Empty file removed bigquery/__init__.py
Empty file.
Empty file removed bigquery/api/__init__.py
Empty file.
5 changes: 2 additions & 3 deletions bigquery/api/async_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import json

from async_query import main
import testing

from .async_query import main


class TestAsyncQuery(testing.CloudTest):

Expand Down
9 changes: 3 additions & 6 deletions bigquery/api/export_data_to_cloud_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

"""Tests for export_table_to_gcs."""
from nose.plugins.attrib import attr
from export_data_to_cloud_storage import main
import pytest
from testing import CloudTest

from .export_data_to_cloud_storage import main


@attr('slow')
@pytest.mark.slow
class TestExportTableToGCS(CloudTest):
dataset_id = 'test_dataset'
table_id = 'test_table'
Expand Down
5 changes: 2 additions & 3 deletions bigquery/api/getting_started_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re

from getting_started import main
import testing

from .getting_started import main


class TestGettingStarted(testing.CloudTest):
def test_main(self):
Expand Down
5 changes: 2 additions & 3 deletions bigquery/api/list_datasets_projects_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re

from list_datasets_projects import main
import testing

from .list_datasets_projects import main


class TestListDatasetsProjects(testing.CloudTest):

Expand Down
Loading

0 comments on commit 95d112e

Please sign in to comment.