本文整理匯總了Python中google.rpc.status_pb2.Status方法的典型用法代碼示例。如果您正苦於以下問題:Python status_pb2.Status方法的具體用法?Python status_pb2.Status怎麽用?Python status_pb2.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.rpc.status_pb2
的用法示例。
在下文中一共展示了status_pb2.Status方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update_field_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_update_field_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_update_field_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = firestore_admin_v1.FirestoreAdminClient()
# Setup Request
field = {}
response = client.update_field(field)
exception = response.exception()
assert exception.errors[0] == error
示例2: test_create_index_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_create_index_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_create_index_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = firestore_admin_v1.FirestoreAdminClient()
# Setup Request
parent = client.collection_group_path("[PROJECT]", "[DATABASE]", "[COLLECTION]")
index = {}
response = client.create_index(parent, index)
exception = response.exception()
assert exception.errors[0] == error
示例3: test_export_documents_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_export_documents_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_export_documents_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = firestore_admin_v1.FirestoreAdminClient()
# Setup Request
name = client.database_path("[PROJECT]", "[DATABASE]")
response = client.export_documents(name)
exception = response.exception()
assert exception.errors[0] == error
示例4: test_import_documents_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_import_documents_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_import_documents_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = firestore_admin_v1.FirestoreAdminClient()
# Setup Request
name = client.database_path("[PROJECT]", "[DATABASE]")
response = client.import_documents(name)
exception = response.exception()
assert exception.errors[0] == error
示例5: __init__
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def __init__(self, grpc_error):
assert (grpc_error.code() == grpc.StatusCode.UNKNOWN)
self.grpc_error = grpc_error
error = None
# The gRPC Python package does not have a convenient way to access the
# binary details for the error: they are treated as trailing metadata.
for meta in self.grpc_error.trailing_metadata():
if meta[0] == "grpc-status-details-bin":
error = status_pb2.Status()
error.ParseFromString(meta[1])
break
if error is None:
raise P4RuntimeErrorFormatException("No binary details field")
# if len(error.details) == 0:
# raise P4RuntimeErrorFormatException(
# "Binary details field has empty Any details repeated field")
self.errors = error.details
self.idx = 0
示例6: decode
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def decode(
self, status: Status, message: Optional[str], data: bytes,
) -> Sequence[Any]:
status_pb2 = _status_pb2()
sym_db = _sym_db()
status_proto = status_pb2.Status.FromString(data)
details = []
for detail_container in status_proto.details:
try:
msg_type = sym_db.GetSymbol(detail_container.TypeName())
except KeyError:
details.append(_Unknown(detail_container.TypeName()))
continue
detail = msg_type()
detail_container.Unpack(detail)
details.append(detail)
return details
示例7: test_batch_update_intents_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_update_intents_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_update_intents_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.IntentsClient()
# Setup Request
parent = client.project_agent_path("[PROJECT]")
response = client.batch_update_intents(parent)
exception = response.exception()
assert exception.errors[0] == error
示例8: test_batch_delete_intents_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_delete_intents_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_delete_intents_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.IntentsClient()
# Setup Request
parent = client.project_agent_path("[PROJECT]")
intents = []
response = client.batch_delete_intents(parent, intents)
exception = response.exception()
assert exception.errors[0] == error
示例9: test_batch_update_entity_types_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_update_entity_types_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_update_entity_types_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.EntityTypesClient()
# Setup Request
parent = client.project_agent_path("[PROJECT]")
response = client.batch_update_entity_types(parent)
exception = response.exception()
assert exception.errors[0] == error
示例10: test_batch_delete_entity_types_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_delete_entity_types_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_delete_entity_types_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.EntityTypesClient()
# Setup Request
parent = client.project_agent_path("[PROJECT]")
entity_type_names = []
response = client.batch_delete_entity_types(parent, entity_type_names)
exception = response.exception()
assert exception.errors[0] == error
示例11: test_batch_create_entities_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_create_entities_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_create_entities_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.EntityTypesClient()
# Setup Request
parent = client.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
entities = []
response = client.batch_create_entities(parent, entities)
exception = response.exception()
assert exception.errors[0] == error
示例12: test_batch_delete_entities_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_batch_delete_entities_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_batch_delete_entities_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.EntityTypesClient()
# Setup Request
parent = client.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
entity_values = []
response = client.batch_delete_entities(parent, entity_values)
exception = response.exception()
assert exception.errors[0] == error
示例13: test_create_document_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_create_document_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_create_document_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.DocumentsClient()
# Setup Request
parent = client.knowledge_base_path("[PROJECT]", "[KNOWLEDGE_BASE]")
document = {}
response = client.create_document(parent, document)
exception = response.exception()
assert exception.errors[0] == error
示例14: test_delete_document_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_delete_document_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_delete_document_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.DocumentsClient()
# Setup Request
name = client.document_path("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]")
response = client.delete_document(name)
exception = response.exception()
assert exception.errors[0] == error
示例15: test_update_document_exception
# 需要導入模塊: from google.rpc import status_pb2 [as 別名]
# 或者: from google.rpc.status_pb2 import Status [as 別名]
def test_update_document_exception(self):
# Setup Response
error = status_pb2.Status()
operation = operations_pb2.Operation(
name="operations/test_update_document_exception", done=True
)
operation.error.CopyFrom(error)
# Mock the API response
channel = ChannelStub(responses=[operation])
patch = mock.patch("google.api_core.grpc_helpers.create_channel")
with patch as create_channel:
create_channel.return_value = channel
client = dialogflow_v2beta1.DocumentsClient()
# Setup Request
document = {}
response = client.update_document(document)
exception = response.exception()
assert exception.errors[0] == error