Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(spanner): propagate errors from 'Transaction.batch_update' #9393

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions spanner/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
import uuid

import pytest
from google.rpc import code_pb2

from google.api_core import exceptions
from google.api_core.datetime_helpers import DatetimeWithNanoseconds

from google.cloud.spanner_v1 import param_types
from google.cloud.spanner_v1.proto.type_pb2 import ARRAY
from google.cloud.spanner_v1.proto.type_pb2 import BOOL
Expand Down Expand Up @@ -776,6 +778,11 @@ def test_transaction_execute_update_then_insert_commit(self):
# [END spanner_test_dml_update]
# [END spanner_test_dml_with_mutation]

@staticmethod
def _check_batch_status(status_code):
if status_code != code_pb2.OK:
raise exceptions.from_grpc_status(status_code, "batch_update failed")

def test_transaction_batch_update_success(self):
# [START spanner_test_dml_with_mutation]
# [START spanner_test_dml_update]
Expand Down Expand Up @@ -808,7 +815,7 @@ def unit_of_work(transaction, self):
status, row_counts = transaction.batch_update(
[insert_statement, update_statement, delete_statement]
)
self.assertEqual(status.code, 0) # XXX: where are values defined?
self._check_batch_status(status.code)
self.assertEqual(len(row_counts), 3)
for row_count in row_counts:
self.assertEqual(row_count, 1)
Expand Down Expand Up @@ -849,7 +856,7 @@ def unit_of_work(transaction, self):
status, row_counts = transaction.batch_update(
insert_statements + update_statements
)
self.assertEqual(status.code, 0) # XXX: where are values defined?
self._check_batch_status(status.code)
self.assertEqual(len(row_counts), len(insert_statements) + 1)
for row_count in row_counts:
self.assertEqual(row_count, 1)
Expand Down