File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -211,8 +211,8 @@ def create(self):
211211 if exc_to_code (exc .cause ) == StatusCode .ALREADY_EXISTS :
212212 raise Conflict (self .name )
213213 elif exc_to_code (exc .cause ) == StatusCode .NOT_FOUND :
214- raise NotFound ('Instance not found: {name}' .format (
215- name = self . _instance . name ,
214+ raise NotFound ('Database not found: {name}' .format (
215+ name = db_name ,
216216 ))
217217 raise
218218
Original file line number Diff line number Diff line change 3636
3737from google .cloud ._helpers import UTC
3838from google .cloud .exceptions import GrpcRendezvous
39+ from google .cloud .exceptions import NotFound
3940from google .cloud .spanner_v1 ._helpers import TimestampWithNanoseconds
4041from google .cloud .spanner import Client
4142from google .cloud .spanner import KeyRange
@@ -282,6 +283,18 @@ def test_create_database(self):
282283 for database in Config .INSTANCE .list_databases ()]
283284 self .assertIn (temp_db_id , database_ids )
284285
286+ def test_create_database_not_found (self ):
287+ temp_db_id = 'temp_db' + unique_resource_id ('_' )
288+ temp_db = Config .INSTANCE .database ("bitemporal_pattern1" , ddl_statements = [
289+ """CREATE TABLE MyTable (
290+ Id String(36) NOT NULL,
291+ Field1 STRING(36) NOT NULL
292+ ) PRIMARY KEY (Id)""" ,
293+ """CREATE INDEX IDX ON yTable (Field1)"""
294+ ])
295+ with self .assertRaisesRegexp (NotFound , "Database not found" ):
296+ operation = temp_db .create ()
297+
285298 def test_update_database_ddl (self ):
286299 pool = BurstyPool ()
287300 temp_db_id = 'temp_db' + unique_resource_id ('_' )
You can’t perform that action at this time.
0 commit comments