@@ -76,18 +76,15 @@ async def test_s3_source(anon_connection_config: S3ConnectionConfig):
7676 ),
7777 )
7878
79+
7980@pytest .mark .asyncio
8081@pytest .mark .tags (CONNECTOR_TYPE , SOURCE_TAG , BLOB_STORAGE_TAG )
8182async def test_s3_source_special_char (anon_connection_config : S3ConnectionConfig ):
82- indexer_config = S3IndexerConfig (
83- remote_url = "s3://utic-dev-tech-fixtures/special-characters/"
84- )
83+ indexer_config = S3IndexerConfig (remote_url = "s3://utic-dev-tech-fixtures/special-characters/" )
8584 with tempfile .TemporaryDirectory () as tempdir :
8685 tempdir_path = Path (tempdir )
8786 download_config = S3DownloaderConfig (download_dir = tempdir_path )
88- indexer = S3Indexer (
89- connection_config = anon_connection_config , index_config = indexer_config
90- )
87+ indexer = S3Indexer (connection_config = anon_connection_config , index_config = indexer_config )
9188 downloader = S3Downloader (
9289 connection_config = anon_connection_config , download_config = download_config
9390 )
@@ -108,26 +105,23 @@ async def test_s3_source_special_char(anon_connection_config: S3ConnectionConfig
108105 ),
109106 )
110107
108+
111109@pytest .mark .tags (CONNECTOR_TYPE , SOURCE_TAG , BLOB_STORAGE_TAG )
112110def test_s3_source_no_access (anon_connection_config : S3ConnectionConfig ):
113- indexer_config = S3IndexerConfig (
114- remote_url = "s3://utic-ingest-test-fixtures/destination/"
115- )
116- indexer = S3Indexer (
117- connection_config = anon_connection_config , index_config = indexer_config
118- )
111+ indexer_config = S3IndexerConfig (remote_url = "s3://utic-ingest-test-fixtures/destination/" )
112+ indexer = S3Indexer (connection_config = anon_connection_config , index_config = indexer_config )
119113 with pytest .raises (UserAuthError ):
120114 indexer .precheck ()
121115
116+
122117@pytest .mark .tags (CONNECTOR_TYPE , SOURCE_TAG , BLOB_STORAGE_TAG )
123118def test_s3_source_no_bucket (anon_connection_config : S3ConnectionConfig ):
124119 indexer_config = S3IndexerConfig (remote_url = "s3://fake-bucket" )
125- indexer = S3Indexer (
126- connection_config = anon_connection_config , index_config = indexer_config
127- )
120+ indexer = S3Indexer (connection_config = anon_connection_config , index_config = indexer_config )
128121 with pytest .raises (UserError ):
129122 indexer .precheck ()
130123
124+
131125@pytest .mark .asyncio
132126@pytest .mark .tags (CONNECTOR_TYPE , SOURCE_TAG , "minio" , BLOB_STORAGE_TAG )
133127async def test_s3_minio_source (anon_connection_config : S3ConnectionConfig ):
@@ -139,9 +133,7 @@ async def test_s3_minio_source(anon_connection_config: S3ConnectionConfig):
139133 ):
140134 tempdir_path = Path (tempdir )
141135 download_config = S3DownloaderConfig (download_dir = tempdir_path )
142- indexer = S3Indexer (
143- connection_config = anon_connection_config , index_config = indexer_config
144- )
136+ indexer = S3Indexer (connection_config = anon_connection_config , index_config = indexer_config )
145137 downloader = S3Downloader (
146138 connection_config = anon_connection_config , download_config = download_config
147139 )
@@ -167,13 +159,15 @@ async def test_s3_minio_source(anon_connection_config: S3ConnectionConfig):
167159 ),
168160 )
169161
162+
170163def get_aws_credentials () -> dict :
171164 access_key = os .getenv ("S3_INGEST_TEST_ACCESS_KEY" , None )
172165 assert access_key
173166 secret_key = os .getenv ("S3_INGEST_TEST_SECRET_KEY" , None )
174167 assert secret_key
175168 return {"aws_access_key_id" : access_key , "aws_secret_access_key" : secret_key }
176169
170+
177171@pytest .mark .asyncio
178172@pytest .mark .tags (CONNECTOR_TYPE , DESTINATION_TAG , BLOB_STORAGE_TAG )
179173@requires_env ("S3_INGEST_TEST_ACCESS_KEY" , "S3_INGEST_TEST_SECRET_KEY" )
@@ -191,9 +185,7 @@ async def test_s3_destination(upload_file: Path):
191185 uploader = S3Uploader (connection_config = connection_config , upload_config = upload_config )
192186 s3fs = uploader .fs
193187 file_data = FileData (
194- source_identifiers = SourceIdentifiers (
195- fullpath = upload_file .name , filename = upload_file .name
196- ),
188+ source_identifiers = SourceIdentifiers (fullpath = upload_file .name , filename = upload_file .name ),
197189 connector_type = CONNECTOR_TYPE ,
198190 identifier = "mock file data" ,
199191 )
@@ -204,14 +196,13 @@ async def test_s3_destination(upload_file: Path):
204196 else :
205197 uploader .run (path = upload_file , file_data = file_data )
206198 uploaded_files = [
207- Path (file )
208- for file in s3fs .ls (path = destination_path )
209- if Path (file ).name != "_empty"
199+ Path (file ) for file in s3fs .ls (path = destination_path ) if Path (file ).name != "_empty"
210200 ]
211201 assert len (uploaded_files ) == 1
212202 finally :
213203 s3fs .rm (path = destination_path , recursive = True )
214204
205+
215206@pytest .mark .asyncio
216207@pytest .mark .tags (CONNECTOR_TYPE , DESTINATION_TAG , BLOB_STORAGE_TAG )
217208@requires_env ("S3_INGEST_TEST_ACCESS_KEY" , "S3_INGEST_TEST_SECRET_KEY" )
@@ -252,14 +243,13 @@ async def test_s3_destination_same_filename_different_folders(upload_file: Path)
252243 uploader .run (path = upload_file , file_data = file_data_1 )
253244 uploader .run (path = upload_file , file_data = file_data_2 )
254245 uploaded_files = [
255- Path (file )
256- for file in s3fs .ls (path = destination_path )
257- if Path (file ).name != "_empty"
246+ Path (file ) for file in s3fs .ls (path = destination_path ) if Path (file ).name != "_empty"
258247 ]
259248 assert len (uploaded_files ) == 2
260249 finally :
261250 s3fs .rm (path = destination_path , recursive = True )
262251
252+
263253@pytest .mark .asyncio
264254@pytest .mark .tags (CONNECTOR_TYPE , DESTINATION_TAG , BLOB_STORAGE_TAG )
265255@requires_env ("S3_INGEST_TEST_ACCESS_KEY" , "S3_INGEST_TEST_SECRET_KEY" )
@@ -292,9 +282,7 @@ async def test_s3_destination_different_relative_path_and_full_path(upload_file:
292282 else :
293283 uploader .run (path = upload_file , file_data = file_data )
294284 uploaded_files = [
295- Path (file )
296- for file in s3fs .ls (path = destination_path )
297- if Path (file ).name != "_empty"
285+ Path (file ) for file in s3fs .ls (path = destination_path ) if Path (file ).name != "_empty"
298286 ]
299287 assert len (uploaded_files ) == 1
300288 assert uploaded_files [0 ].as_posix () == f"{ destination_path .lstrip ('s3://' )} /folder1"
0 commit comments