File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -211,8 +211,8 @@ def create(self):
211
211
if exc_to_code (exc .cause ) == StatusCode .ALREADY_EXISTS :
212
212
raise Conflict (self .name )
213
213
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 ,
216
216
))
217
217
raise
218
218
Original file line number Diff line number Diff line change 36
36
37
37
from google .cloud ._helpers import UTC
38
38
from google .cloud .exceptions import GrpcRendezvous
39
+ from google .cloud .exceptions import NotFound
39
40
from google .cloud .spanner_v1 ._helpers import TimestampWithNanoseconds
40
41
from google .cloud .spanner import Client
41
42
from google .cloud .spanner import KeyRange
@@ -282,6 +283,18 @@ def test_create_database(self):
282
283
for database in Config .INSTANCE .list_databases ()]
283
284
self .assertIn (temp_db_id , database_ids )
284
285
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
+
285
298
def test_update_database_ddl (self ):
286
299
pool = BurstyPool ()
287
300
temp_db_id = 'temp_db' + unique_resource_id ('_' )
You can’t perform that action at this time.
0 commit comments