55import pytest
66from deltalake import DeltaTable
77from fsspec import get_filesystem_class
8+ from pydantic import Secret
89
910from test .integration .connectors .utils .constants import DESTINATION_TAG , SQL_TAG
1011from test .integration .utils import requires_env
2728async def test_delta_table_destination_local (upload_file : Path , temp_dir : Path ):
2829 destination_path = str (temp_dir )
2930 connection_config = DeltaTableConnectionConfig (
30- access_config = DeltaTableAccessConfig (),
31+ access_config = Secret ( DeltaTableAccessConfig () ),
3132 table_uri = destination_path ,
3233 )
3334 stager_config = DeltaTableUploadStagerConfig ()
3435 stager = DeltaTableUploadStager (upload_stager_config = stager_config )
36+
37+ mock_file_data = FileData (
38+ identifier = "mock file data" ,
39+ connector_type = CONNECTOR_TYPE ,
40+ source_identifiers = SourceIdentifiers (
41+ filename = upload_file .name ,
42+ fullpath = upload_file .name ,
43+ ),
44+ )
45+
3546 new_upload_file = stager .run (
3647 elements_filepath = upload_file ,
48+ file_data = mock_file_data ,
3749 output_dir = temp_dir ,
3850 output_filename = upload_file .name ,
3951 )
@@ -52,11 +64,10 @@ async def test_delta_table_destination_local(upload_file: Path, temp_dir: Path):
5264 await uploader .run_async (path = new_upload_file , file_data = file_data )
5365 else :
5466 uploader .run (path = new_upload_file , file_data = file_data )
55- delta_table_path = os .path .join (destination_path , upload_file .name )
56- delta_table = DeltaTable (table_uri = delta_table_path )
67+ delta_table = DeltaTable (table_uri = destination_path )
5768 df = delta_table .to_pandas ()
5869
59- EXPECTED_COLUMNS = 10
70+ EXPECTED_COLUMNS = 11
6071 EXPECTED_ROWS = 22
6172 assert len (df ) == EXPECTED_ROWS , (
6273 f"Number of rows in table vs expected: { len (df )} /{ EXPECTED_ROWS } "
@@ -86,17 +97,30 @@ async def test_delta_table_destination_s3(upload_file: Path, temp_dir: Path):
8697 s3_bucket = "s3://utic-platform-test-destination"
8798 destination_path = f"{ s3_bucket } /destination/test"
8899 connection_config = DeltaTableConnectionConfig (
89- access_config = DeltaTableAccessConfig (
90- aws_access_key_id = aws_credentials ["AWS_ACCESS_KEY_ID" ],
91- aws_secret_access_key = aws_credentials ["AWS_SECRET_ACCESS_KEY" ],
100+ access_config = Secret (
101+ DeltaTableAccessConfig (
102+ aws_access_key_id = aws_credentials ["AWS_ACCESS_KEY_ID" ],
103+ aws_secret_access_key = aws_credentials ["AWS_SECRET_ACCESS_KEY" ],
104+ )
92105 ),
93106 aws_region = aws_credentials ["AWS_REGION" ],
94107 table_uri = destination_path ,
95108 )
96109 stager_config = DeltaTableUploadStagerConfig ()
97110 stager = DeltaTableUploadStager (upload_stager_config = stager_config )
111+
112+ mock_file_data = FileData (
113+ identifier = "mock file data" ,
114+ connector_type = CONNECTOR_TYPE ,
115+ source_identifiers = SourceIdentifiers (
116+ filename = upload_file .name ,
117+ fullpath = upload_file .name ,
118+ ),
119+ )
120+
98121 new_upload_file = stager .run (
99122 elements_filepath = upload_file ,
123+ file_data = mock_file_data ,
100124 output_dir = temp_dir ,
101125 output_filename = upload_file .name ,
102126 )
@@ -117,11 +141,10 @@ async def test_delta_table_destination_s3(upload_file: Path, temp_dir: Path):
117141 await uploader .run_async (path = new_upload_file , file_data = file_data )
118142 else :
119143 uploader .run (path = new_upload_file , file_data = file_data )
120- delta_table_path = os .path .join (destination_path , upload_file .name )
121- delta_table = DeltaTable (table_uri = delta_table_path , storage_options = aws_credentials )
144+ delta_table = DeltaTable (table_uri = destination_path , storage_options = aws_credentials )
122145 df = delta_table .to_pandas ()
123146
124- EXPECTED_COLUMNS = 10
147+ EXPECTED_COLUMNS = 11
125148 EXPECTED_ROWS = 22
126149 assert len (df ) == EXPECTED_ROWS , (
127150 f"Number of rows in table vs expected: { len (df )} /{ EXPECTED_ROWS } "
@@ -149,17 +172,30 @@ async def test_delta_table_destination_s3_bad_creds(upload_file: Path, temp_dir:
149172 s3_bucket = "s3://utic-platform-test-destination"
150173 destination_path = f"{ s3_bucket } /destination/test"
151174 connection_config = DeltaTableConnectionConfig (
152- access_config = DeltaTableAccessConfig (
153- aws_access_key_id = aws_credentials ["AWS_ACCESS_KEY_ID" ],
154- aws_secret_access_key = aws_credentials ["AWS_SECRET_ACCESS_KEY" ],
175+ access_config = Secret (
176+ DeltaTableAccessConfig (
177+ aws_access_key_id = aws_credentials ["AWS_ACCESS_KEY_ID" ],
178+ aws_secret_access_key = aws_credentials ["AWS_SECRET_ACCESS_KEY" ],
179+ )
155180 ),
156181 aws_region = aws_credentials ["AWS_REGION" ],
157182 table_uri = destination_path ,
158183 )
159184 stager_config = DeltaTableUploadStagerConfig ()
160185 stager = DeltaTableUploadStager (upload_stager_config = stager_config )
186+
187+ mock_file_data = FileData (
188+ identifier = "mock file data" ,
189+ connector_type = CONNECTOR_TYPE ,
190+ source_identifiers = SourceIdentifiers (
191+ filename = upload_file .name ,
192+ fullpath = upload_file .name ,
193+ ),
194+ )
195+
161196 new_upload_file = stager .run (
162197 elements_filepath = upload_file ,
198+ file_data = mock_file_data ,
163199 output_dir = temp_dir ,
164200 output_filename = upload_file .name ,
165201 )
0 commit comments