Skip to content

Commit

Permalink
Merge pull request #34 from GoogleCloudPlatform/jw-coverage
Browse files Browse the repository at this point in the history
Fixing coverage, fixing pep8 issues
  • Loading branch information
Jeff Mendoza committed May 22, 2015
2 parents f17f951 + 64f0487 commit ea29c67
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[run]
include =
appengine/*
bigquery/*
datastore/*
localtesting/*
bigquery/*
storage/*
[report]
exclude_lines =
pragma: NO COVER
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Google Cloud SDK installation path.
$ export TEST_BUCKET_NAME={YOUR_BUCKET_NAME}
$ tox

## Adding new tests

Common testing utilities are located under ``tests``.

When adding a new directory, be sure to edit ``.coveragerc`` to include it in coveralls.

## Licensing

* See [LICENSE](LICENSE)
5 changes: 3 additions & 2 deletions bigquery/samples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def get_service():
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
if credentials.create_scoped_required():
credentials = credentials.create_scoped('https://www.googleapis.com/auth/bigquery')
return build('bigquery','v2', credentials=GoogleCredentials.get_application_default())
credentials = credentials.create_scoped(
'https://www.googleapis.com/auth/bigquery')
return build('bigquery', 'v2', credentials=credentials)
# [END get_service]


Expand Down
17 changes: 9 additions & 8 deletions bigquery/tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import os
import unittest

from bigquery.samples.async_query import run, main
from tests import CloudBaseTest, mock_raw_input, BUCKET_NAME_ENV, \
PROJECT_ID_ENV
from bigquery.samples.async_query import main, run

class TestAsyncQuery(CloudBaseTest):
import tests


class TestAsyncQuery(tests.CloudBaseTest):

def test_async_query(self):
for result in run(self.constants['projectId'],
Expand All @@ -30,14 +31,14 @@ def test_async_query(self):
self.assertIsNotNone(json.loads(result))


class TestAsyncRunner(CloudBaseTest):
class TestAsyncRunner(tests.CloudBaseTest):

def test_async_query_runner(self):
test_bucket_name = os.environ.get(BUCKET_NAME_ENV)
test_project_id = os.environ.get(PROJECT_ID_ENV)
test_bucket_name = os.environ.get(tests.BUCKET_NAME_ENV)
test_project_id = os.environ.get(tests.PROJECT_ID_ENV)
answers = [test_bucket_name, test_project_id, 'n',
'1', '1']
with mock_raw_input(answers):
with tests.mock_raw_input(answers):
main()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from datastore.ndb.modeling import structured_property_models as models

from tests import DatastoreTestbedCase
from tests import DatastoreTestbedCase


class ContactTestCase(DatastoreTestbedCase):
Expand Down
1 change: 1 addition & 0 deletions discoverydoccaching/discovery_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
RESOURCE_PATH = '..' # look for discovery docs in the parent folder
MAX_AGE = 86400 # update discovery docs older than a day


def build_and_update(api, version, scopes=None):
from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build_from_document
Expand Down
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
Common testing utilities between samples
"""

import __builtin__
import json
import os
import unittest
import __builtin__

from google.appengine.datastore import datastore_stub_util
from google.appengine.ext import testbed
Expand Down Expand Up @@ -81,6 +81,7 @@ def setUp(self):
def tearDown(self):
os.environ['SERVER_SOFTWARE'] = self._server_software_org


class DatastoreTestbedCase(unittest.TestCase):
"""A base test case for common setup/teardown tasks for test."""
def setUp(self):
Expand Down

0 comments on commit ea29c67

Please sign in to comment.