@@ -55,17 +55,12 @@ def test_tdm_init_metadata_file_found_success(timdex_metadata):
5555
5656
5757def test_tdm_duckdb_context_creates_metadata_schema (timdex_metadata ):
58- assert (
59- timdex_metadata .conn .query (
60- """
58+ assert timdex_metadata .conn .query ("""
6159 select count(*)
6260 from information_schema.schemata
6361 where catalog_name = 'memory'
6462 and schema_name = 'metadata';
65- """
66- ).fetchone ()[0 ]
67- == 1
68- )
63+ """ ).fetchone ()[0 ] == 1
6964
7065
7166def test_tdm_connection_has_static_database_attached (timdex_metadata ):
@@ -241,38 +236,32 @@ def test_tdm_current_records_with_deltas_logic(timdex_metadata_with_deltas):
241236
242237def test_tdm_current_records_most_recent_version (timdex_metadata_with_deltas ):
243238 # check that for records with multiple versions, only the most recent is returned
244- multi_version_records = timdex_metadata_with_deltas .conn .query (
245- """
239+ multi_version_records = timdex_metadata_with_deltas .conn .query ("""
246240 select timdex_record_id, count(*) as version_count
247241 from metadata.records
248242 group by timdex_record_id
249243 having count(*) > 1
250244 limit 1;
251- """
252- ).to_df ()
245+ """ ).to_df ()
253246
254247 if len (multi_version_records ) > 0 :
255248 record_id = multi_version_records .iloc [0 ]["timdex_record_id" ]
256249
257250 # get most recent timestamp for this record
258- most_recent = timdex_metadata_with_deltas .conn .query (
259- f"""
251+ most_recent = timdex_metadata_with_deltas .conn .query (f"""
260252 select run_timestamp, run_id
261253 from metadata.records
262254 where timdex_record_id = '{ record_id } '
263255 order by run_timestamp desc
264256 limit 1;
265- """
266- ).to_df ()
257+ """ ).to_df ()
267258
268259 # verify current_records contains this version
269- current_version = timdex_metadata_with_deltas .conn .query (
270- f"""
260+ current_version = timdex_metadata_with_deltas .conn .query (f"""
271261 select run_timestamp, run_id
272262 from metadata.current_records
273263 where timdex_record_id = '{ record_id } ';
274- """
275- ).to_df ()
264+ """ ).to_df ()
276265
277266 assert len (current_version ) == 1
278267 assert (
@@ -294,21 +283,17 @@ def test_tdm_merge_append_deltas_static_counts_match_records_count_before_merge(
294283def test_tdm_merge_append_deltas_adds_records_to_static_db (
295284 timdex_metadata_with_deltas , timdex_metadata_merged_deltas
296285):
297- append_deltas = timdex_metadata_with_deltas .conn .query (
298- f"""
286+ append_deltas = timdex_metadata_with_deltas .conn .query (f"""
299287 select
300288 { ',' .join (ORDERED_METADATA_COLUMN_NAMES )}
301289 from metadata.append_deltas
302- """
303- ).to_df ()
290+ """ ).to_df ()
304291
305- merged_static_db = timdex_metadata_merged_deltas .conn .query (
306- f"""
292+ merged_static_db = timdex_metadata_merged_deltas .conn .query (f"""
307293 select
308294 { ',' .join (ORDERED_METADATA_COLUMN_NAMES )}
309295 from static_db.records
310- """
311- ).to_df ()
296+ """ ).to_df ()
312297
313298 assert set (map (tuple , append_deltas .to_numpy ())).issubset (
314299 set (map (tuple , merged_static_db .to_numpy ()))
@@ -332,18 +317,12 @@ def test_td_prepare_duckdb_secret_and_extensions_home_env_var_set_and_valid(
332317 monkeypatch .setenv ("HOME" , str (preset_home ))
333318
334319 td = TIMDEXDataset (timdex_dataset_with_runs .location )
335- df = (
336- td .conn .query (
337- """
320+ df = td .conn .query ("""
338321 select
339322 current_setting('secret_directory') as secret_directory,
340323 current_setting('extension_directory') as extension_directory
341324 ;
342- """
343- )
344- .to_df ()
345- .iloc [0 ]
346- )
325+ """ ).to_df ().iloc [0 ]
347326 assert "my-account" in df .secret_directory
348327 assert df .extension_directory == "" # expected and okay when HOME set
349328
@@ -355,18 +334,12 @@ def test_td_prepare_duckdb_secret_and_extensions_home_env_var_unset(
355334
356335 td = TIMDEXDataset (timdex_dataset_with_runs .location )
357336
358- df = (
359- td .conn .query (
360- """
337+ df = td .conn .query ("""
361338 select
362339 current_setting('secret_directory') as secret_directory,
363340 current_setting('extension_directory') as extension_directory
364341 ;
365- """
366- )
367- .to_df ()
368- .iloc [0 ]
369- )
342+ """ ).to_df ().iloc [0 ]
370343 assert df .secret_directory == "/tmp/.duckdb/secrets"
371344 assert df .extension_directory == "/tmp/.duckdb/extensions"
372345
@@ -378,18 +351,12 @@ def test_td_prepare_duckdb_secret_and_extensions_home_env_var_set_but_empty(
378351
379352 td = TIMDEXDataset (timdex_dataset_with_runs .location )
380353
381- df = (
382- td .conn .query (
383- """
354+ df = td .conn .query ("""
384355 select
385356 current_setting('secret_directory') as secret_directory,
386357 current_setting('extension_directory') as extension_directory
387358 ;
388- """
389- )
390- .to_df ()
391- .iloc [0 ]
392- )
359+ """ ).to_df ().iloc [0 ]
393360 assert df .secret_directory == "/tmp/.duckdb/secrets"
394361 assert df .extension_directory == "/tmp/.duckdb/extensions"
395362
@@ -411,16 +378,14 @@ def test_tdm_preload_false_no_temp_table(timdex_dataset_with_runs):
411378 td = TIMDEXDataset (timdex_dataset_with_runs .location )
412379
413380 # assert that materialized, temporary table "temp.current_records" does not exist
414- temp_table_count = td .metadata .conn .query (
415- """
381+ temp_table_count = td .metadata .conn .query ("""
416382 select count(*)
417383 from information_schema.tables
418384 where table_catalog = 'temp'
419385 and table_name = 'current_records'
420386 and table_type = 'LOCAL TEMPORARY'
421387 ;
422- """
423- ).fetchone ()[0 ]
388+ """ ).fetchone ()[0 ]
424389
425390 assert temp_table_count == 0
426391
@@ -430,15 +395,13 @@ def test_tdm_preload_true_has_temp_table(timdex_dataset_with_runs):
430395 td = TIMDEXDataset (timdex_dataset_with_runs .location , preload_current_records = True )
431396
432397 # assert that materialized, temporary table "temp.current_records" does exist
433- temp_table_count = td .metadata .conn .query (
434- """
398+ temp_table_count = td .metadata .conn .query ("""
435399 select count(*)
436400 from information_schema.tables
437401 where table_catalog = 'temp'
438402 and table_name = 'current_records'
439403 and table_type = 'LOCAL TEMPORARY'
440404 ;
441- """
442- ).fetchone ()[0 ]
405+ """ ).fetchone ()[0 ]
443406
444407 assert temp_table_count == 1
0 commit comments