Skip to content

Commit

Permalink
Changing Operation._use_grpc to _from_grpc.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Oct 31, 2016
1 parent bdc9f52 commit 0328268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions core/google/cloud/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Operation(object):
converted into the correct types.
"""

_use_grpc = True
_from_grpc = True

def __init__(self, name, client, **caller_metadata):
self.name = name
Expand All @@ -160,7 +160,7 @@ def from_pb(cls, operation_pb, client, **caller_metadata):
"""
result = cls(operation_pb.name, client, **caller_metadata)
result._update_state(operation_pb)
result._use_grpc = True
result._from_grpc = True
return result

@classmethod
Expand All @@ -183,7 +183,7 @@ def from_dict(cls, operation, client, **caller_metadata):
operation, operations_pb2.Operation())
result = cls(operation_pb.name, client, **caller_metadata)
result._update_state(operation_pb)
result._use_grpc = False
result._from_grpc = False
return result

@property
Expand Down Expand Up @@ -226,7 +226,7 @@ def _get_operation(self):
:rtype: :class:`~google.longrunning.operations_pb2.Operation`
:returns: The latest status of the current operation.
"""
if self._use_grpc:
if self._from_grpc:
return self._get_operation_rpc()
else:
return self._get_operation_http()
Expand Down
8 changes: 4 additions & 4 deletions core/unit_tests/test_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_ctor_defaults(self):
self.assertIsNone(operation.error)
self.assertIsNone(operation.metadata)
self.assertEqual(operation.caller_metadata, {})
self.assertTrue(operation._use_grpc)
self.assertTrue(operation._from_grpc)

def test_ctor_explicit(self):
client = _Client()
Expand All @@ -124,7 +124,7 @@ def test_ctor_explicit(self):
self.assertIsNone(operation.error)
self.assertIsNone(operation.metadata)
self.assertEqual(operation.caller_metadata, {'foo': 'bar'})
self.assertTrue(operation._use_grpc)
self.assertTrue(operation._from_grpc)

def test_from_pb_wo_metadata_or_kw(self):
from google.longrunning import operations_pb2
Expand Down Expand Up @@ -219,7 +219,7 @@ def test_from_dict(self):
self.assertEqual(
operation.metadata.fields['foo'].string_value, 'Bar')
self.assertEqual(operation.caller_metadata, {})
self.assertFalse(operation._use_grpc)
self.assertFalse(operation._from_grpc)

def test_complete_property(self):
client = _Client()
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_poll_http(self):
connection = _Connection(api_response)
client = _Client(connection)
operation = self._makeOne(name, client)
operation._use_grpc = False
operation._from_grpc = False

with _Monkey(MUT, _TYPE_URL_MAP={type_url: Struct}):
self.assertTrue(operation.poll())
Expand Down

0 comments on commit 0328268

Please sign in to comment.