Skip to content

Commit

Permalink
Renaming makeResource -> make_resource. (#4355)
Browse files Browse the repository at this point in the history
Done via:

  $ git grep -l makeResource | xargs sed -i s/makeResource/make_resource/g
  • Loading branch information
dhermes committed Nov 7, 2017
1 parent 1ed56fd commit 9396bc1
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 89 deletions.
4 changes: 2 additions & 2 deletions bigquery/tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _setUpConstants(self):
self.DS_FULL_ID = '%s:%s' % (self.PROJECT, self.DS_ID)
self.RESOURCE_URL = 'http://example.com/path/to/resource'

def _makeResource(self):
def _make_resource(self):
self._setUpConstants()
USER_EMAIL = 'phred@example.com'
GROUP_EMAIL = 'group-name@lists.example.com'
Expand Down Expand Up @@ -422,7 +422,7 @@ def test_from_api_repr_bare(self):
self._verify_resource_properties(dataset, RESOURCE)

def test_from_api_repr_w_properties(self):
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
klass = self._get_target_class()
dataset = klass.from_api_repr(RESOURCE)
self._verify_resource_properties(dataset, RESOURCE)
Expand Down
88 changes: 44 additions & 44 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _table_ref(self, table_id):

return TableReference(self.DS_REF, table_id)

def _makeResource(self, started=False, ended=False):
def _make_resource(self, started=False, ended=False):
self._setUpConstants()
resource = {
'configuration': {
Expand Down Expand Up @@ -219,8 +219,8 @@ def _setUpConstants(self):
self.OUTPUT_BYTES = 23456
self.OUTPUT_ROWS = 345

def _makeResource(self, started=False, ended=False):
resource = super(TestLoadJob, self)._makeResource(
def _make_resource(self, started=False, ended=False):
resource = super(TestLoadJob, self)._make_resource(
started, ended)
config = resource['configuration']['load']
config['sourceUris'] = [self.SOURCE1]
Expand Down Expand Up @@ -374,21 +374,21 @@ def test_ctor_w_config(self):

def test_done(self):
client = _make_client(project=self.PROJECT)
resource = self._makeResource(ended=True)
resource = self._make_resource(ended=True)
job = self._get_target_class().from_api_repr(resource, client)
self.assertTrue(job.done())

def test_result(self):
client = _make_client(project=self.PROJECT)
resource = self._makeResource(ended=True)
resource = self._make_resource(ended=True)
job = self._get_target_class().from_api_repr(resource, client)

result = job.result()

self.assertIs(result, job)

def test_result_invokes_begin(self):
begun_resource = self._makeResource()
begun_resource = self._make_resource()
done_resource = copy.deepcopy(begun_resource)
done_resource['status'] = {'state': 'DONE'}
connection = _Connection(begun_resource, done_resource)
Expand Down Expand Up @@ -537,7 +537,7 @@ def test_from_api_repr_bare(self):

def test_from_api_repr_w_properties(self):
client = _make_client(project=self.PROJECT)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
load_config = RESOURCE['configuration']['load']
load_config['createDisposition'] = 'CREATE_IF_NEEDED'
klass = self._get_target_class()
Expand All @@ -557,7 +557,7 @@ def test_begin_w_already_running(self):

def test_begin_w_bound_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -595,7 +595,7 @@ def test_begin_w_bound_client(self):

def test_begin_w_autodetect(self):
path = '/projects/{}/jobs'.format(self.PROJECT)
resource = self._makeResource()
resource = self._make_resource()
resource['configuration']['load']['autodetect'] = True
# Ensure None for missing server-set props
del resource['statistics']['creationTime']
Expand Down Expand Up @@ -639,7 +639,7 @@ def test_begin_w_alternate_client(self):
from google.cloud.bigquery.schema import SchemaField

PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
LOAD_CONFIGURATION = {
'sourceUris': [self.SOURCE1],
'destinationTable': {
Expand Down Expand Up @@ -743,7 +743,7 @@ def test_exists_hit_w_alternate_client(self):

def test_reload_w_bound_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn = _Connection(RESOURCE)
client = _make_client(project=self.PROJECT, connection=conn)
table = _Table()
Expand All @@ -759,7 +759,7 @@ def test_reload_w_bound_client(self):

def test_reload_w_alternate_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn1 = _Connection()
client1 = _make_client(project=self.PROJECT, connection=conn1)
conn2 = _Connection(RESOURCE)
Expand All @@ -778,7 +778,7 @@ def test_reload_w_alternate_client(self):

def test_cancel_w_bound_client(self):
PATH = '/projects/%s/jobs/%s/cancel' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
RESPONSE = {'job': RESOURCE}
conn = _Connection(RESPONSE)
client = _make_client(project=self.PROJECT, connection=conn)
Expand All @@ -795,7 +795,7 @@ def test_cancel_w_bound_client(self):

def test_cancel_w_alternate_client(self):
PATH = '/projects/%s/jobs/%s/cancel' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
RESPONSE = {'job': RESOURCE}
conn1 = _Connection()
client1 = _make_client(project=self.PROJECT, connection=conn1)
Expand Down Expand Up @@ -825,8 +825,8 @@ def _get_target_class():

return CopyJob

def _makeResource(self, started=False, ended=False):
resource = super(TestCopyJob, self)._makeResource(
def _make_resource(self, started=False, ended=False):
resource = super(TestCopyJob, self)._make_resource(
started, ended)
config = resource['configuration']['copy']
config['sourceTables'] = [{
Expand Down Expand Up @@ -997,7 +997,7 @@ def test_from_api_repr_wo_sources(self):

def test_from_api_repr_w_properties(self):
client = _make_client(project=self.PROJECT)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
copy_config = RESOURCE['configuration']['copy']
copy_config['createDisposition'] = 'CREATE_IF_NEEDED'
klass = self._get_target_class()
Expand All @@ -1007,7 +1007,7 @@ def test_from_api_repr_w_properties(self):

def test_begin_w_bound_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def test_begin_w_bound_client(self):

def test_begin_w_alternate_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
COPY_CONFIGURATION = {
'sourceTables': [{
'projectId': self.PROJECT,
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def test_exists_hit_w_alternate_client(self):

def test_reload_w_bound_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn = _Connection(RESOURCE)
client = _make_client(project=self.PROJECT, connection=conn)
source = self._table_ref(self.SOURCE_TABLE)
Expand All @@ -1151,7 +1151,7 @@ def test_reload_w_bound_client(self):

def test_reload_w_alternate_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn1 = _Connection()
client1 = _make_client(project=self.PROJECT, connection=conn1)
conn2 = _Connection(RESOURCE)
Expand Down Expand Up @@ -1181,8 +1181,8 @@ def _get_target_class():

return ExtractJob

def _makeResource(self, started=False, ended=False):
resource = super(TestExtractJob, self)._makeResource(
def _make_resource(self, started=False, ended=False):
resource = super(TestExtractJob, self)._make_resource(
started, ended)
config = resource['configuration']['extract']
config['sourceTable'] = {
Expand Down Expand Up @@ -1316,7 +1316,7 @@ def test_from_api_repr_bare(self):

def test_from_api_repr_w_properties(self):
client = _make_client(project=self.PROJECT)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
extract_config = RESOURCE['configuration']['extract']
extract_config['compression'] = 'GZIP'
klass = self._get_target_class()
Expand All @@ -1326,7 +1326,7 @@ def test_from_api_repr_w_properties(self):

def test_begin_w_bound_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def test_begin_w_bound_client(self):

def test_begin_w_alternate_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
EXTRACT_CONFIGURATION = {
'sourceTable': {
'projectId': self.PROJECT,
Expand Down Expand Up @@ -1450,7 +1450,7 @@ def test_exists_hit_w_alternate_client(self):

def test_reload_w_bound_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn = _Connection(RESOURCE)
client = _make_client(project=self.PROJECT, connection=conn)
source_dataset = DatasetReference(self.PROJECT, self.DS_ID)
Expand All @@ -1468,7 +1468,7 @@ def test_reload_w_bound_client(self):

def test_reload_w_alternate_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn1 = _Connection()
client1 = _make_client(project=self.PROJECT, connection=conn1)
conn2 = _Connection(RESOURCE)
Expand Down Expand Up @@ -1562,8 +1562,8 @@ def _get_target_class():

return QueryJob

def _makeResource(self, started=False, ended=False):
resource = super(TestQueryJob, self)._makeResource(
def _make_resource(self, started=False, ended=False):
resource = super(TestQueryJob, self)._make_resource(
started, ended)
config = resource['configuration']['query']
config['query'] = self.QUERY
Expand Down Expand Up @@ -1788,7 +1788,7 @@ def test_from_api_repr_bare(self):

def test_from_api_repr_w_properties(self):
client = _make_client(project=self.PROJECT)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
query_config = RESOURCE['configuration']['query']
query_config['createDisposition'] = 'CREATE_IF_NEEDED'
query_config['writeDisposition'] = 'WRITE_TRUNCATE'
Expand Down Expand Up @@ -1816,7 +1816,7 @@ def test_cancelled(self):

def test_done(self):
client = _make_client(project=self.PROJECT)
resource = self._makeResource(ended=True)
resource = self._make_resource(ended=True)
job = self._get_target_class().from_api_repr(resource, client)
self.assertTrue(job.done())

Expand Down Expand Up @@ -2137,15 +2137,15 @@ def test_result(self):
}
connection = _Connection(query_resource, query_resource)
client = _make_client(self.PROJECT, connection=connection)
resource = self._makeResource(ended=True)
resource = self._make_resource(ended=True)
job = self._get_target_class().from_api_repr(resource, client)

result = job.result()

self.assertEqual(list(result), [])

def test_result_invokes_begins(self):
begun_resource = self._makeResource()
begun_resource = self._make_resource()
incomplete_resource = {
'jobComplete': False,
'jobReference': {
Expand All @@ -2172,7 +2172,7 @@ def test_result_invokes_begins(self):
self.assertEqual(reload_request['method'], 'GET')

def test_result_w_timeout(self):
begun_resource = self._makeResource()
begun_resource = self._make_resource()
query_resource = {
'jobComplete': True,
'jobReference': {
Expand Down Expand Up @@ -2229,7 +2229,7 @@ def test_begin_w_bound_client(self):

PATH = '/projects/%s/jobs' % (self.PROJECT,)
DS_ID = 'DATASET'
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2277,7 +2277,7 @@ def test_begin_w_alternate_client(self):
PATH = '/projects/%s/jobs' % (self.PROJECT,)
TABLE = 'TABLE'
DS_ID = 'DATASET'
RESOURCE = self._makeResource(ended=True)
RESOURCE = self._make_resource(ended=True)
QUERY_CONFIGURATION = {
'query': self.QUERY,
'allowLargeResults': True,
Expand Down Expand Up @@ -2351,7 +2351,7 @@ def test_begin_w_udf(self):
RESOURCE_URI = 'gs://some-bucket/js/lib.js'
INLINE_UDF_CODE = 'var someCode = "here";'
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2405,7 +2405,7 @@ def test_begin_w_named_query_parameter(self):

query_parameters = [ScalarQueryParameter('foo', 'INT64', 123)]
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2461,7 +2461,7 @@ def test_begin_w_positional_query_parameter(self):

query_parameters = [ScalarQueryParameter.positional('INT64', 123)]
PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2517,7 +2517,7 @@ def test_begin_w_table_defs(self):
from google.cloud.bigquery.external_config import BigtableColumnFamily

PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2601,7 +2601,7 @@ def test_dry_run_query(self):
from google.cloud.bigquery.job import QueryJobConfig

PATH = '/projects/%s/jobs' % (self.PROJECT,)
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
# Ensure None for missing server-set props
del RESOURCE['statistics']['creationTime']
del RESOURCE['etag']
Expand Down Expand Up @@ -2675,7 +2675,7 @@ def test_reload_w_bound_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
DS_ID = 'DATASET'
DEST_TABLE = 'dest_table'
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
conn = _Connection(RESOURCE)
client = _make_client(project=self.PROJECT, connection=conn)
dataset_ref = DatasetReference(self.PROJECT, DS_ID)
Expand All @@ -2698,7 +2698,7 @@ def test_reload_w_alternate_client(self):
PATH = '/projects/%s/jobs/%s' % (self.PROJECT, self.JOB_ID)
DS_ID = 'DATASET'
DEST_TABLE = 'dest_table'
RESOURCE = self._makeResource()
RESOURCE = self._make_resource()
q_config = RESOURCE['configuration']['query']
q_config['destinationTable'] = {
'projectId': self.PROJECT,
Expand Down
Loading

0 comments on commit 9396bc1

Please sign in to comment.