Skip to content

Commit 4930c3d

Browse files
author
Jon Wayne Parrott
committed
Re-organizing some test stuff.
* 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.
1 parent b3ea84d commit 4930c3d

15 files changed

+18
-85
lines changed

bigquery/test/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

bigquery/test/base_test.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

bigquery/tests/__init__.py

Whitespace-only changes.

bigquery/test/test_async_query.py renamed to bigquery/tests/test_async_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import unittest
1616

1717
from bigquery.samples.async_query import run
18-
from bigquery.test.base_test import BaseBigqueryTest
18+
from tests import CloudBaseTest
1919

2020

21-
class TestAsyncQuery(BaseBigqueryTest):
21+
class TestAsyncQuery(CloudBaseTest):
2222

2323
def test_async_query(self):
2424
for result in run(self.constants['projectId'],

bigquery/test/test_export_data_to_cloud_storage.py renamed to bigquery/tests/test_export_data_to_cloud_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import unittest
1818

1919
from bigquery.samples.export_data_to_cloud_storage import run
20-
from bigquery.test.base_test import BaseBigqueryTest
20+
from tests import CloudBaseTest
2121

2222

23-
class TestExportTableToGCS(BaseBigqueryTest):
23+
class TestExportTableToGCS(CloudBaseTest):
2424

2525
def test_export_table(self):
2626
run(self.constants['cloudStorageInputURI'],

bigquery/test/test_load_data_from_csv.py renamed to bigquery/tests/test_load_data_from_csv.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@
1818
import unittest
1919

2020
from bigquery.samples.load_data_from_csv import run
21-
from bigquery.test import RESOURCE_PATH
22-
from bigquery.test.base_test import BaseBigqueryTest
21+
from tests import CloudBaseTest
2322

2423

25-
class TestLoadDataFromCSV(BaseBigqueryTest):
24+
class TestLoadDataFromCSV(CloudBaseTest):
2625

2726
def setUp(self):
2827
super(TestLoadDataFromCSV, self).setUp()
2928
with open(
30-
os.path.join(RESOURCE_PATH, 'schema.json'),
29+
os.path.join(self.resource_path, 'schema.json'),
3130
'r') as schema_file:
3231
self.schema = json.load(schema_file)
3332

bigquery/test/test_streaming.py renamed to bigquery/tests/test_streaming.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
import unittest
1818

1919
from bigquery.samples.streaming import run
20-
from bigquery.test import RESOURCE_PATH
21-
from bigquery.test.base_test import BaseBigqueryTest
20+
from tests import CloudBaseTest
2221

2322

24-
class TestStreaming(BaseBigqueryTest):
23+
class TestStreaming(CloudBaseTest):
2524

2625
def test_stream_row_to_bigquery(self):
2726

2827
with open(
29-
os.path.join(RESOURCE_PATH, 'streamrows.json'),
28+
os.path.join(self.resource_path, 'streamrows.json'),
3029
'r') as rows_file:
3130

3231
rows = json.load(rows_file)

bigquery/test/test_sync_query.py renamed to bigquery/tests/test_sync_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import unittest
1616

1717
from bigquery.samples.sync_query import run
18-
from bigquery.test.base_test import BaseBigqueryTest
18+
from tests import CloudBaseTest
1919

2020

21-
class TestSyncQuery(BaseBigqueryTest):
21+
class TestSyncQuery(CloudBaseTest):
2222

2323
def test_sync_query(self):
2424
for result in run(self.constants['projectId'],

storage/tests/test_list_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def test_main(self):
2121
'ignored_command_name',
2222
self.constants['bucketName']
2323
]
24-
self.assertNotRaises(main(args))
24+
main(args)

tests/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222

2323
BUCKET_NAME_ENV = 'TEST_BUCKET_NAME'
2424
PROJECT_ID_ENV = 'TEST_PROJECT_ID'
25-
RESOURCE_PATH = os.path.join(os.getcwd(), 'resources')
25+
RESOURCE_PATH = os.path.join(
26+
os.path.abspath(os.path.dirname(__file__)), 'resources')
2627

2728

2829
class CloudBaseTest(unittest.TestCase):
2930

3031
def setUp(self):
32+
self.resource_path = RESOURCE_PATH
33+
3134
# A hack to prevent get_application_default from going GAE route.
3235
self._server_software_org = os.environ.get('SERVER_SOFTWARE')
3336
os.environ['SERVER_SOFTWARE'] = ''
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ commands =
2222
cover: --cover-tests --cover-branches --cover-min-percentage=70 \
2323
cover: --cover-inclusive --cover-erase
2424
cover: coveralls
25-
nosetest: nosetests --with-gae
25+
nosetest: nosetests --with-gae {posargs}
2626
pep8: flake8 --max-complexity=10 --import-order-style=google

0 commit comments

Comments
 (0)