@@ -120,9 +120,15 @@ def test_get_articles(self) -> None:
120120 assert output .records
121121
122122 def test_get_article_attachments (self ) -> None :
123- with HttpMocker () as http_mocker , patch (
124- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write' ) as mock_noop_write , patch (
125- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write' ) as mock_file_system_write :
123+ with (
124+ HttpMocker () as http_mocker ,
125+ patch (
126+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write"
127+ ) as mock_noop_write ,
128+ patch (
129+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write"
130+ ) as mock_file_system_write ,
131+ ):
126132 http_mocker .get (
127133 HttpRequest (url = STREAM_URL ),
128134 HttpResponse (json .dumps (find_template ("file_api/articles" , __file__ )), 200 ),
@@ -146,7 +152,11 @@ def test_get_article_attachments(self) -> None:
146152 output = read (
147153 self ._config (),
148154 CatalogBuilder ()
149- .with_stream (ConfiguredAirbyteStreamBuilder ().with_name ("article_attachments" ).with_include_files (True ))
155+ .with_stream (
156+ ConfiguredAirbyteStreamBuilder ()
157+ .with_name ("article_attachments" )
158+ .with_include_files (True )
159+ )
150160 .build (),
151161 )
152162
@@ -190,19 +200,31 @@ def test_get_article_attachments_and_file_is_uploaded(self) -> None:
190200 output = read (
191201 self ._config (),
192202 CatalogBuilder ()
193- .with_stream (ConfiguredAirbyteStreamBuilder ().with_name ("article_attachments" ).with_include_files (True ))
203+ .with_stream (
204+ ConfiguredAirbyteStreamBuilder ()
205+ .with_name ("article_attachments" )
206+ .with_include_files (True )
207+ )
194208 .build (),
195209 yaml_file = "test_file_stream_with_filename_extractor.yaml" ,
196210 )
197211 file_reference = output .records [0 ].record .file_reference
198212 assert file_reference .file_size_bytes
199- assert Path (file_reference .staging_file_url ).exists (), "File should be uploaded to the staging directory"
213+ assert Path (file_reference .staging_file_url ).exists (), (
214+ "File should be uploaded to the staging directory"
215+ )
200216
201217 def test_get_article_attachments_with_filename_extractor (self ) -> None :
202218 """Test that article attachments can be read with filename extractor and file system writer is called"""
203- with HttpMocker () as http_mocker , patch (
204- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write' ) as mock_noop_write , patch (
205- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write' ) as mock_file_system_write :
219+ with (
220+ HttpMocker () as http_mocker ,
221+ patch (
222+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write"
223+ ) as mock_noop_write ,
224+ patch (
225+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write"
226+ ) as mock_file_system_write ,
227+ ):
206228 http_mocker .get (
207229 HttpRequest (url = STREAM_URL ),
208230 HttpResponse (json .dumps (find_template ("file_api/articles" , __file__ )), 200 ),
@@ -226,7 +248,11 @@ def test_get_article_attachments_with_filename_extractor(self) -> None:
226248 output = read (
227249 self ._config (),
228250 CatalogBuilder ()
229- .with_stream (ConfiguredAirbyteStreamBuilder ().with_name ("article_attachments" ).with_include_files (True ))
251+ .with_stream (
252+ ConfiguredAirbyteStreamBuilder ()
253+ .with_name ("article_attachments" )
254+ .with_include_files (True )
255+ )
230256 .build (),
231257 yaml_file = "test_file_stream_with_filename_extractor.yaml" ,
232258 )
@@ -251,9 +277,15 @@ def test_get_article_attachments_with_filename_extractor(self) -> None:
251277 def test_get_article_attachments_without_include_files (self ) -> None :
252278 """Test that article attachments can be read without including files, it can be opt-out by configured catalog"""
253279 include_files = False
254- with HttpMocker () as http_mocker , patch (
255- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write' ) as mock_noop_write , patch (
256- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write' ) as mock_file_system_write :
280+ with (
281+ HttpMocker () as http_mocker ,
282+ patch (
283+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write"
284+ ) as mock_noop_write ,
285+ patch (
286+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write"
287+ ) as mock_file_system_write ,
288+ ):
257289 http_mocker .get (
258290 HttpRequest (url = STREAM_URL ),
259291 HttpResponse (json .dumps (find_template ("file_api/articles" , __file__ )), 200 ),
@@ -276,7 +308,11 @@ def test_get_article_attachments_without_include_files(self) -> None:
276308 output = read (
277309 self ._config (),
278310 CatalogBuilder ()
279- .with_stream (ConfiguredAirbyteStreamBuilder ().with_name ("article_attachments" ).with_include_files (include_files ))
311+ .with_stream (
312+ ConfiguredAirbyteStreamBuilder ()
313+ .with_name ("article_attachments" )
314+ .with_include_files (include_files )
315+ )
280316 .build (),
281317 yaml_file = "test_file_stream_with_filename_extractor.yaml" ,
282318 )
@@ -300,9 +336,15 @@ def test_get_article_attachments_without_include_files(self) -> None:
300336 assert file_reference .file_size_bytes == NoopFileWriter .NOOP_FILE_SIZE
301337
302338 def test_get_article_attachments_messages_for_connector_builder (self ) -> None :
303- with HttpMocker () as http_mocker , patch (
304- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write' ) as mock_noop_write , patch (
305- 'airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write' ) as mock_file_system_write :
339+ with (
340+ HttpMocker () as http_mocker ,
341+ patch (
342+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.noop_file_writer.NoopFileWriter.write"
343+ ) as mock_noop_write ,
344+ patch (
345+ "airbyte_cdk.sources.declarative.retrievers.file_uploader.local_file_system_file_writer.LocalFileSystemFileWriter.write"
346+ ) as mock_file_system_write ,
347+ ):
306348 http_mocker .get (
307349 HttpRequest (url = STREAM_URL ),
308350 HttpResponse (json .dumps (find_template ("file_api/articles" , __file__ )), 200 ),
@@ -337,7 +379,11 @@ def __init__(self, *args, **kwargs):
337379 output = read (
338380 self ._config (),
339381 CatalogBuilder ()
340- .with_stream (ConfiguredAirbyteStreamBuilder ().with_name ("article_attachments" ).with_include_files (True ))
382+ .with_stream (
383+ ConfiguredAirbyteStreamBuilder ()
384+ .with_name ("article_attachments" )
385+ .with_include_files (True )
386+ )
341387 .build (),
342388 yaml_file = "test_file_stream_with_filename_extractor.yaml" ,
343389 )
0 commit comments