Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 0 additions & 19 deletions spanner/google/cloud/spanner/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

"""User friendly container for Cloud Spanner Database."""

import functools
import re

from google.gax.errors import GaxError
from google.gax.grpc import exc_to_code
from google.gax import _OperationFuture
from google.cloud.proto.spanner.admin.database.v1 import (
spanner_database_admin_pb2 as admin_v1_pb2)
from google.cloud.gapic.spanner.v1.spanner_client import SpannerClient
Expand Down Expand Up @@ -51,22 +49,6 @@
register_type(admin_v1_pb2.UpdateDatabaseDdlMetadata)


class _BrokenResultFuture(_OperationFuture):
"""An _OperationFuture subclass that is permissive about type mismatches
in results, and simply returns an empty-ish object if they happen.

This class exists to get past a contra-spec result on
`update_database_ddl`; since the result is empty there is no
critical loss.
"""
@functools.wraps(_OperationFuture.result)
def result(self, *args, **kwargs):
try:
return super(_BrokenResultFuture, self).result(*args, **kwargs)
except TypeError:
return self._result_type()


class Database(object):
"""Representation of a Cloud Spanner Database.

Expand Down Expand Up @@ -280,7 +262,6 @@ def update_ddl(self, ddl_statements):
try:
future = api.update_database_ddl(
self.name, ddl_statements, '', options=options)
future.__class__ = _BrokenResultFuture
except GaxError as exc:
if exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
raise NotFound(self.name)
Expand Down
24 changes: 0 additions & 24 deletions spanner/unit_tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import unittest

import mock

from google.cloud.spanner import __version__

from google.cloud._testing import _GAXBaseAPI
Expand Down Expand Up @@ -1010,28 +1008,6 @@ class Testing(Exception):
self.assertIs(pool._session, session)


class TestBrokenResultFuture(unittest.TestCase):
def test_result_normal(self):
from google.gax import _OperationFuture
from google.cloud.spanner.database import _BrokenResultFuture

with mock.patch.object(_OperationFuture, 'result') as super_result:
super_result.return_value = 'foo'
brf = _BrokenResultFuture(object(), object(), str, object())
self.assertEqual(brf.result(), 'foo')
super_result.assert_called_once()

def test_result_valueerror(self):
from google.gax import _OperationFuture
from google.cloud.spanner.database import _BrokenResultFuture

with mock.patch.object(_OperationFuture, 'result') as super_result:
super_result.side_effect = TypeError
brf = _BrokenResultFuture(object(), object(), str, object())
self.assertEqual(brf.result(), '')
super_result.assert_called_once()


class _Client(object):

def __init__(self, project=TestDatabase.PROJECT_ID):
Expand Down