Skip to content

Commit

Permalink
Re-organizing some test stuff.
Browse files Browse the repository at this point in the history
* Bigquery and storage tests extend from common tests.CloudBaseTest.
* All test resources now live in tests/resources, accessible via self.resources inside of tests.
* Updated tox to allow testing a single file for dev purposes.
  • Loading branch information
Jon Wayne Parrott committed May 21, 2015
1 parent b3ea84d commit bfc1353
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 85 deletions.
19 changes: 0 additions & 19 deletions bigquery/test/__init__.py

This file was deleted.

49 changes: 0 additions & 49 deletions bigquery/test/base_test.py

This file was deleted.

Empty file added bigquery/tests/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import unittest

from bigquery.samples.async_query import run
from bigquery.test.base_test import BaseBigqueryTest
from tests import CloudBaseTest


class TestAsyncQuery(BaseBigqueryTest):
class TestAsyncQuery(CloudBaseTest):

def test_async_query(self):
for result in run(self.constants['projectId'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import unittest

from bigquery.samples.export_data_to_cloud_storage import run
from bigquery.test.base_test import BaseBigqueryTest
from tests import CloudBaseTest


class TestExportTableToGCS(BaseBigqueryTest):
class TestExportTableToGCS(CloudBaseTest):

def test_export_table(self):
run(self.constants['cloudStorageInputURI'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
import unittest

from bigquery.samples.load_data_from_csv import run
from bigquery.test import RESOURCE_PATH
from bigquery.test.base_test import BaseBigqueryTest
from tests import CloudBaseTest


class TestLoadDataFromCSV(BaseBigqueryTest):
class TestLoadDataFromCSV(CloudBaseTest):

def setUp(self):
super(TestLoadDataFromCSV, self).setUp()
with open(
os.path.join(RESOURCE_PATH, 'schema.json'),
os.path.join(self.resource_path, 'schema.json'),
'r') as schema_file:
self.schema = json.load(schema_file)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
import unittest

from bigquery.samples.streaming import run
from bigquery.test import RESOURCE_PATH
from bigquery.test.base_test import BaseBigqueryTest
from tests import CloudBaseTest


class TestStreaming(BaseBigqueryTest):
class TestStreaming(CloudBaseTest):

def test_stream_row_to_bigquery(self):

with open(
os.path.join(RESOURCE_PATH, 'streamrows.json'),
os.path.join(self.resource_path, 'streamrows.json'),
'r') as rows_file:

rows = json.load(rows_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import unittest

from bigquery.samples.sync_query import run
from bigquery.test.base_test import BaseBigqueryTest
from tests import CloudBaseTest


class TestSyncQuery(BaseBigqueryTest):
class TestSyncQuery(CloudBaseTest):

def test_sync_query(self):
for result in run(self.constants['projectId'],
Expand Down
2 changes: 1 addition & 1 deletion storage/tests/test_list_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def test_main(self):
'ignored_command_name',
self.constants['bucketName']
]
self.assertNotRaises(main(args))
main(args)
5 changes: 4 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

BUCKET_NAME_ENV = 'TEST_BUCKET_NAME'
PROJECT_ID_ENV = 'TEST_PROJECT_ID'
RESOURCE_PATH = os.path.join(os.getcwd(), 'resources')
RESOURCE_PATH = os.path.join(
os.path.abspath(os.path.dirname(__file__)), 'resources')


class CloudBaseTest(unittest.TestCase):

def setUp(self):
self.resource_path = RESOURCE_PATH

# A hack to prevent get_application_default from going GAE route.
self._server_software_org = os.environ.get('SERVER_SOFTWARE')
os.environ['SERVER_SOFTWARE'] = ''
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ commands =
cover: --cover-tests --cover-branches --cover-min-percentage=70 \
cover: --cover-inclusive --cover-erase
cover: coveralls
nosetest: nosetests --with-gae
nosetest: nosetests --with-gae []
pep8: flake8 --max-complexity=10 --import-order-style=google

0 comments on commit bfc1353

Please sign in to comment.