Skip to content

Commit ea29c67

Browse files
author
Jeff Mendoza
committed
Merge pull request #34 from GoogleCloudPlatform/jw-coverage
Fixing coverage, fixing pep8 issues
2 parents f17f951 + 64f0487 commit ea29c67

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed

.coveragerc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[run]
22
include =
3+
appengine/*
4+
bigquery/*
35
datastore/*
46
localtesting/*
5-
bigquery/*
7+
storage/*
68
[report]
79
exclude_lines =
810
pragma: NO COVER

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Google Cloud SDK installation path.
3333
$ export TEST_BUCKET_NAME={YOUR_BUCKET_NAME}
3434
$ tox
3535

36+
## Adding new tests
37+
38+
Common testing utilities are located under ``tests``.
39+
40+
When adding a new directory, be sure to edit ``.coveragerc`` to include it in coveralls.
41+
3642
## Licensing
3743

3844
* See [LICENSE](LICENSE)

bigquery/samples/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def get_service():
1919
from oauth2client.client import GoogleCredentials
2020
credentials = GoogleCredentials.get_application_default()
2121
if credentials.create_scoped_required():
22-
credentials = credentials.create_scoped('https://www.googleapis.com/auth/bigquery')
23-
return build('bigquery','v2', credentials=GoogleCredentials.get_application_default())
22+
credentials = credentials.create_scoped(
23+
'https://www.googleapis.com/auth/bigquery')
24+
return build('bigquery', 'v2', credentials=credentials)
2425
# [END get_service]
2526

2627

bigquery/tests/test_async_query.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
import os
1616
import unittest
1717

18-
from bigquery.samples.async_query import run, main
19-
from tests import CloudBaseTest, mock_raw_input, BUCKET_NAME_ENV, \
20-
PROJECT_ID_ENV
18+
from bigquery.samples.async_query import main, run
2119

22-
class TestAsyncQuery(CloudBaseTest):
20+
import tests
21+
22+
23+
class TestAsyncQuery(tests.CloudBaseTest):
2324

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

3233

33-
class TestAsyncRunner(CloudBaseTest):
34+
class TestAsyncRunner(tests.CloudBaseTest):
3435

3536
def test_async_query_runner(self):
36-
test_bucket_name = os.environ.get(BUCKET_NAME_ENV)
37-
test_project_id = os.environ.get(PROJECT_ID_ENV)
37+
test_bucket_name = os.environ.get(tests.BUCKET_NAME_ENV)
38+
test_project_id = os.environ.get(tests.PROJECT_ID_ENV)
3839
answers = [test_bucket_name, test_project_id, 'n',
3940
'1', '1']
40-
with mock_raw_input(answers):
41+
with tests.mock_raw_input(answers):
4142
main()
4243

4344

datastore/ndb/modeling/tests/test_structured_property_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from datastore.ndb.modeling import structured_property_models as models
1818

19-
from tests import DatastoreTestbedCase
19+
from tests import DatastoreTestbedCase
2020

2121

2222
class ContactTestCase(DatastoreTestbedCase):

discoverydoccaching/discovery_doc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
RESOURCE_PATH = '..' # look for discovery docs in the parent folder
2828
MAX_AGE = 86400 # update discovery docs older than a day
2929

30+
3031
def build_and_update(api, version, scopes=None):
3132
from oauth2client.client import GoogleCredentials
3233
from googleapiclient.discovery import build_from_document

tests/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
Common testing utilities between samples
1616
"""
1717

18+
import __builtin__
1819
import json
1920
import os
2021
import unittest
21-
import __builtin__
2222

2323
from google.appengine.datastore import datastore_stub_util
2424
from google.appengine.ext import testbed
@@ -81,6 +81,7 @@ def setUp(self):
8181
def tearDown(self):
8282
os.environ['SERVER_SOFTWARE'] = self._server_software_org
8383

84+
8485
class DatastoreTestbedCase(unittest.TestCase):
8586
"""A base test case for common setup/teardown tasks for test."""
8687
def setUp(self):

0 commit comments

Comments
 (0)