@@ -169,14 +169,6 @@ def test__session_checkout(self, mock_database):
169169 connection ._session_checkout ()
170170 self .assertEqual (connection ._session , "db_session" )
171171
172- def test__session_checkout_database_error (self ):
173- from google .cloud .spanner_dbapi import Connection
174-
175- connection = Connection (INSTANCE )
176-
177- with pytest .raises (ValueError ):
178- connection ._session_checkout ()
179-
180172 @mock .patch ("google.cloud.spanner_v1.database.Database" )
181173 def test__release_session (self , mock_database ):
182174 from google .cloud .spanner_dbapi import Connection
@@ -190,13 +182,6 @@ def test__release_session(self, mock_database):
190182 pool .put .assert_called_once_with ("session" )
191183 self .assertIsNone (connection ._session )
192184
193- def test__release_session_database_error (self ):
194- from google .cloud .spanner_dbapi import Connection
195-
196- connection = Connection (INSTANCE )
197- with pytest .raises (ValueError ):
198- connection ._release_session ()
199-
200185 def test_transaction_checkout (self ):
201186 from google .cloud .spanner_dbapi import Connection
202187
@@ -309,14 +294,6 @@ def test_commit(self, mock_warn):
309294 AUTOCOMMIT_MODE_WARNING , UserWarning , stacklevel = 2
310295 )
311296
312- def test_commit_database_error (self ):
313- from google .cloud .spanner_dbapi import Connection
314-
315- connection = Connection (INSTANCE )
316-
317- with pytest .raises (ValueError ):
318- connection .commit ()
319-
320297 @mock .patch .object (warnings , "warn" )
321298 def test_rollback (self , mock_warn ):
322299 from google .cloud .spanner_dbapi import Connection
@@ -370,13 +347,6 @@ def test_run_prior_DDL_statements(self, mock_database):
370347 with self .assertRaises (InterfaceError ):
371348 connection .run_prior_DDL_statements ()
372349
373- def test_run_prior_DDL_statements_database_error (self ):
374- from google .cloud .spanner_dbapi import Connection
375-
376- connection = Connection (INSTANCE )
377- with pytest .raises (ValueError ):
378- connection .run_prior_DDL_statements ()
379-
380350 def test_as_context_manager (self ):
381351 connection = self ._make_connection ()
382352 with connection as conn :
@@ -796,14 +766,6 @@ def test_validate_error(self):
796766
797767 snapshot_obj .execute_sql .assert_called_once_with ("SELECT 1" )
798768
799- def test_validate_database_error (self ):
800- from google .cloud .spanner_dbapi import Connection
801-
802- connection = Connection (INSTANCE )
803-
804- with pytest .raises (ValueError ):
805- connection .validate ()
806-
807769 def test_validate_closed (self ):
808770 from google .cloud .spanner_dbapi .exceptions import InterfaceError
809771
@@ -954,14 +916,16 @@ def test_request_priority(self):
954916 sql , params , param_types = param_types , request_options = None
955917 )
956918
957- def test_custom_client_connection (self ):
919+ @mock .patch ("google.cloud.spanner_v1.Client" )
920+ def test_custom_client_connection (self , mock_client ):
958921 from google .cloud .spanner_dbapi import connect
959922
960923 client = _Client ()
961924 connection = connect ("test-instance" , "test-database" , client = client )
962925 self .assertTrue (connection .instance ._client == client )
963926
964- def test_invalid_custom_client_connection (self ):
927+ @mock .patch ("google.cloud.spanner_v1.Client" )
928+ def test_invalid_custom_client_connection (self , mock_client ):
965929 from google .cloud .spanner_dbapi import connect
966930
967931 client = _Client ()
@@ -973,12 +937,6 @@ def test_invalid_custom_client_connection(self):
973937 client = client ,
974938 )
975939
976- def test_connection_wo_database (self ):
977- from google .cloud .spanner_dbapi import connect
978-
979- connection = connect ("test-instance" )
980- self .assertTrue (connection .database is None )
981-
982940
983941def exit_ctx_func (self , exc_type , exc_value , traceback ):
984942 """Context __exit__ method mock."""
0 commit comments