File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change 11from datetime import datetime
22
33import boto3 # type: ignore
4+ import botocore .exceptions
45import pytest # type: ignore
56
67import awswrangler as wr
@@ -303,6 +304,19 @@ def oracle_table():
303304 con .close ()
304305
305306
307+ @pytest .fixture (scope = "function" )
308+ def timestream_database ():
309+ name = f"tbl_{ get_time_str_with_random_suffix ()} "
310+ print (f"Timestream name: { name } " )
311+ wr .timestream .create_database (name )
312+ yield name
313+ try :
314+ wr .timestream .delete_database (name )
315+ except botocore .exceptions .ClientError as err :
316+ if err .response ["Error" ]["Code" ] == "ResourceNotFound" :
317+ pass
318+
319+
306320@pytest .fixture (scope = "function" )
307321def timestream_database_and_table ():
308322 name = f"tbl_{ get_time_str_with_random_suffix ()} "
Original file line number Diff line number Diff line change @@ -246,26 +246,17 @@ def test_multimeasure_scenario(timestream_database_and_table):
246246 assert df .shape == (3 , 6 )
247247
248248
249- def test_list_databases (timestream_database_and_table ):
249+ def test_list_databases (timestream_database_and_table , timestream_database ):
250250 dbs = wr .timestream .list_databases ()
251251
252252 assert timestream_database_and_table in dbs
253- dummy_db_name = f" { timestream_database_and_table } _2"
253+ assert timestream_database in dbs
254254
255- wr .timestream .create_database (dummy_db_name )
256- dbs_tmp = wr .timestream .list_databases ()
257-
258- assert timestream_database_and_table in dbs_tmp
259- assert dummy_db_name in dbs_tmp
260- assert len (dbs_tmp ) == len (dbs ) + 1
261-
262- wr .timestream .delete_database (dummy_db_name )
255+ wr .timestream .delete_database (timestream_database )
263256
264257 dbs_tmp = wr .timestream .list_databases ()
265258 assert timestream_database_and_table in dbs_tmp
266- assert dummy_db_name not in dbs_tmp
267- assert len (dbs_tmp ) == len (dbs )
268- assert dbs_tmp == dbs
259+ assert timestream_database not in dbs_tmp
269260
270261
271262def test_list_tables (timestream_database_and_table ):
You can’t perform that action at this time.
0 commit comments