11import pytest
2-
32from polars import LazyFrame , Object , String
43from polars .testing import assert_frame_equal
54
65from rdw_ingestion_tools .api import concatenate_to_string_lazyframe , get_polars_schema
76
87
98def test_get_polars_schema_empty_data ():
10- """Tests that schemas generated for empty responses are empty dictionaries.
11- """
9+ """Tests that schemas generated for empty responses are empty dictionaries."""
1210 schema = get_polars_schema (object_columns = [], data = [])
1311
1412 assert schema == {}
@@ -78,7 +76,7 @@ def test_get_polars_schema_json_types():
7876 assert schema == expected_schema
7977
8078
81- @pytest .mark .parametrize ("batch_size" , [1 ,2 ])
79+ @pytest .mark .parametrize ("batch_size" , [1 , 2 ])
8280def test_concatenate_to_string_lazyframe (batch_size ):
8381 """Tests that response data is concatenated and normalised into LazyFrames
8482 with column type `String`.
@@ -88,7 +86,9 @@ def test_concatenate_to_string_lazyframe(batch_size):
8886 {"col1" : 2 , "col2" : [1 , 2 , 3 ], "col3" : {"key" : "value2" }},
8987 ]
9088
91- lf = concatenate_to_string_lazyframe (objs = data , object_columns = ["col2" ], batch_size = batch_size )
89+ lf = concatenate_to_string_lazyframe (
90+ objs = data , object_columns = ["col2" ], batch_size = batch_size
91+ )
9292
9393 expected_lf = LazyFrame (
9494 {
@@ -101,7 +101,7 @@ def test_concatenate_to_string_lazyframe(batch_size):
101101 assert_frame_equal (lf , expected_lf )
102102
103103
104- @pytest .mark .parametrize ("batch_size" , [1 ,2 , 3 ])
104+ @pytest .mark .parametrize ("batch_size" , [1 , 2 , 3 ])
105105def test_concatenate_to_string_lazyframe_uses_all_rows (batch_size ):
106106 """Tests that the key names in every JSON column are used."""
107107 data = [
@@ -113,13 +113,13 @@ def test_concatenate_to_string_lazyframe_uses_all_rows(batch_size):
113113 expected_lf = LazyFrame (
114114 {
115115 "column1_key1" : ["1" , None , None ],
116- "column2_key1" : [None , "1" , "1" ],
117- "column2_key2" : [None , None , "2" ]
116+ "column2_key1" : [None , "1" , "1" ],
117+ "column2_key2" : [None , None , "2" ],
118118 }
119119 )
120120
121- lf = concatenate_to_string_lazyframe (objs = data , object_columns = [], batch_size = batch_size )
121+ lf = concatenate_to_string_lazyframe (
122+ objs = data , object_columns = [], batch_size = batch_size
123+ )
122124
123125 assert_frame_equal (lf , expected_lf )
124-
125-
0 commit comments