File tree 4 files changed +21
-6
lines changed
4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ Google Cloud SDK installation path.
31
31
$ pip install tox
32
32
$ export PYTHONPATH=${GCLOUD}/platform/google_appengine
33
33
$ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
34
+ $ export TEST_PROJECT_ID={YOUR_PROJECT_ID}
35
+ $ export TEST_BUCKET={YOUR_BUCKET_NAME}
34
36
$ tox
35
37
36
38
## Licensing
Original file line number Diff line number Diff line change 18
18
from bigquery .test import RESOURCE_PATH
19
19
20
20
21
+ BUCKET_NAME_ENV = 'TEST_BUCKET_NAME'
22
+ PROJECT_ID_ENV = 'TEST_PROJECT_ID'
23
+
24
+
21
25
class BaseBigqueryTest (unittest .TestCase ):
22
26
23
27
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.
25
29
self ._server_software_org = os .environ .get ('SERVER_SOFTWARE' )
26
30
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 ))
28
37
with open (
29
38
os .path .join (RESOURCE_PATH , 'constants.json' ),
30
39
'r' ) as constants_file :
31
40
32
41
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 )
33
47
34
48
def tearDown (self ):
35
49
os .environ ['SERVER_SOFTWARE' ] = self ._server_software_org
Original file line number Diff line number Diff line change 1
1
{
2
- "projectId" : " bigquery-devrel-samples" ,
3
2
"datasetId" : " test_dataset" ,
4
3
"currentTableId" : " test_table" ,
5
4
"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" ,
8
7
"query" : " SELECT corpus FROM publicdata:samples.shakespeare GROUP BY corpus;"
9
8
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ skipsdist = True
3
3
envlist = {py27}-{nosetest,pep8}, cover
4
4
5
5
[testenv]
6
- passenv = PYTHONPATH GOOGLE_* GCLOUD_* PROJECT_ID TRAVIS*
6
+ passenv = PYTHONPATH GOOGLE_* GCLOUD_* TEST_* TRAVIS*
7
7
basepython =
8
8
cover,py27: python2.7
9
9
deps =
You can’t perform that action at this time.
0 commit comments