File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ Google Cloud SDK installation path.
3131 $ pip install tox
3232 $ export PYTHONPATH=${GCLOUD}/platform/google_appengine
3333 $ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
34+ $ export TEST_PROJECT_ID={YOUR_PROJECT_ID}
35+ $ export TEST_BUCKET={YOUR_BUCKET_NAME}
3436 $ tox
3537
3638## Licensing
Original file line number Diff line number Diff line change 1818from bigquery .test import RESOURCE_PATH
1919
2020
21+ BUCKET_NAME_ENV = 'TEST_BUCKET_NAME'
22+ PROJECT_ID_ENV = 'TEST_PROJECT_ID'
23+
24+
2125class BaseBigqueryTest (unittest .TestCase ):
2226
2327 def setUp (self ):
24- # A hack to prevent get_application_default to choose App Engine route.
28+ # A hack to prevent get_application_default from going GAE route.
2529 self ._server_software_org = os .environ .get ('SERVER_SOFTWARE' )
2630 os .environ ['SERVER_SOFTWARE' ] = ''
27-
31+ test_bucket_name = os .environ .get (BUCKET_NAME_ENV , '' )
32+ test_project_id = os .environ .get (PROJECT_ID_ENV , '' )
33+ if not test_project_id or not test_bucket_name :
34+ raise Exception ('You need to define an env var "%s" and "%s" to '
35+ 'run the test.'
36+ % (PROJECT_ID_ENV , BUCKET_NAME_ENV ))
2837 with open (
2938 os .path .join (RESOURCE_PATH , 'constants.json' ),
3039 'r' ) as constants_file :
3140
3241 self .constants = json .load (constants_file )
42+ self .constants ['projectId' ] = test_project_id
43+ self .constants ['cloudStorageInputURI' ] = (
44+ self .constants ['cloudStorageInputURI' ] % test_bucket_name )
45+ self .constants ['cloudStorageOutputURI' ] = (
46+ self .constants ['cloudStorageOutputURI' ] % test_bucket_name )
3347
3448 def tearDown (self ):
3549 os .environ ['SERVER_SOFTWARE' ] = self ._server_software_org
Original file line number Diff line number Diff line change 11{
2- "projectId" : " bigquery-devrel-samples" ,
32 "datasetId" : " test_dataset" ,
43 "currentTableId" : " test_table" ,
54 "newTableId" : " test_table2" ,
6- "cloudStorageInputURI" : " gs://bigquery-devrel-samples-bucket /data.csv" ,
7- "cloudStorageOutputURI" : " gs://bigquery-devrel-samples-bucket /output.csv" ,
5+ "cloudStorageInputURI" : " gs://%s /data.csv" ,
6+ "cloudStorageOutputURI" : " gs://%s /output.csv" ,
87 "query" : " SELECT corpus FROM publicdata:samples.shakespeare GROUP BY corpus;"
98}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ skipsdist = True
33envlist = {py27}-{nosetest,pep8}, cover
44
55[testenv]
6- passenv = PYTHONPATH GOOGLE_* GCLOUD_* PROJECT_ID TRAVIS*
6+ passenv = PYTHONPATH GOOGLE_* GCLOUD_* TEST_* TRAVIS*
77basepython =
88 cover,py27: python2.7
99deps =
You can’t perform that action at this time.
0 commit comments