Skip to content

Commit 32ec1d9

Browse files
committed
Minor tests adjustments
1 parent b740f64 commit 32ec1d9

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

tests/test_athena.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ def test_athena_ctas(path, path2, path3, glue_table, glue_table2, glue_database,
124124

125125

126126
def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1):
127-
table = f"__{glue_table}"
128-
wr.catalog.delete_table_if_exists(database=glue_database, table=table)
127+
wr.catalog.delete_table_if_exists(database=glue_database, table=glue_table)
129128
wr.s3.to_parquet(
130129
df=get_df(),
131130
path=path,
@@ -134,11 +133,11 @@ def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1
134133
dataset=True,
135134
mode="overwrite",
136135
database=glue_database,
137-
table=table,
136+
table=glue_table,
138137
partition_cols=["par0", "par1"],
139138
)
140139
dfs = wr.athena.read_sql_query(
141-
sql=f"SELECT * FROM {table}",
140+
sql=f"SELECT * FROM {glue_table}",
142141
database=glue_database,
143142
ctas_approach=False,
144143
chunksize=1,
@@ -151,7 +150,7 @@ def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1
151150
ensure_data_types(df=df2)
152151
ensure_athena_query_metadata(df=df2, ctas_approach=False, encrypted=False)
153152
df = wr.athena.read_sql_query(
154-
sql=f"SELECT * FROM {table}",
153+
sql=f"SELECT * FROM {glue_table}",
155154
database=glue_database,
156155
ctas_approach=False,
157156
workgroup=workgroup1,
@@ -160,14 +159,14 @@ def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1
160159
assert len(df.index) == 3
161160
ensure_data_types(df=df)
162161
ensure_athena_query_metadata(df=df, ctas_approach=False, encrypted=False)
163-
wr.athena.repair_table(table=table, database=glue_database)
164-
assert len(wr.athena.describe_table(database=glue_database, table=table).index) > 0
162+
wr.athena.repair_table(table=glue_table, database=glue_database)
163+
assert len(wr.athena.describe_table(database=glue_database, table=glue_table).index) > 0
165164
assert (
166-
wr.catalog.table(database=glue_database, table=table).to_dict()
167-
== wr.athena.describe_table(database=glue_database, table=table).to_dict()
165+
wr.catalog.table(database=glue_database, table=glue_table).to_dict()
166+
== wr.athena.describe_table(database=glue_database, table=glue_table).to_dict()
168167
)
169168
df = wr.athena.read_sql_query(
170-
sql=f"SELECT * FROM {table} WHERE iint8 = :iint8_value;",
169+
sql=f"SELECT * FROM {glue_table} WHERE iint8 = :iint8_value;",
171170
database=glue_database,
172171
ctas_approach=False,
173172
workgroup=workgroup1,
@@ -176,9 +175,9 @@ def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1
176175
)
177176
assert len(df.index) == 1
178177
ensure_athena_query_metadata(df=df, ctas_approach=False, encrypted=False)
179-
query = wr.athena.show_create_table(database=glue_database, table=table)
178+
query = wr.athena.show_create_table(database=glue_database, table=glue_table)
180179
assert (
181-
query.split("LOCATION")[0] == f"CREATE EXTERNAL TABLE `{table}`"
180+
query.split("LOCATION")[0] == f"CREATE EXTERNAL TABLE `{glue_table}`"
182181
f"( `iint8` tinyint,"
183182
f" `iint16` smallint,"
184183
f" `iint32` int,"
@@ -199,7 +198,6 @@ def test_athena(path, glue_database, glue_table, kms_key, workgroup0, workgroup1
199198
f"STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' "
200199
f"OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' "
201200
)
202-
wr.catalog.delete_table_if_exists(database=glue_database, table=table)
203201

204202

205203
def test_catalog(path: str, glue_database: str, glue_table: str) -> None:

tests/test_redshift.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def test_spectrum(path, redshift_table, redshift_con, glue_database, redshift_ex
281281
assert len(rows) == len(df.index)
282282
for row in rows:
283283
assert len(row) == len(df.columns)
284+
wr.catalog.delete_table_if_exists(database=glue_database, table=redshift_table)
284285

285286

286287
def test_category(path, redshift_table, redshift_con, databases_parameters):

0 commit comments

Comments
 (0)