Skip to content

Commit c2232aa

Browse files
committed
Minor - Fix timestream test
1 parent 6882a72 commit c2232aa

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
22

33
import boto3 # type: ignore
4+
import botocore.exceptions
45
import pytest # type: ignore
56

67
import 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")
307321
def timestream_database_and_table():
308322
name = f"tbl_{get_time_str_with_random_suffix()}"

tests/test_timestream.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff 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

271262
def test_list_tables(timestream_database_and_table):

0 commit comments

Comments
 (0)