@@ -317,6 +317,18 @@ def refresh(self) -> None:
317317 pass
318318
319319
320+ def _found_files (* rel_paths : str ):
321+ """Stand in for ``_find_files_in_bundle``, listing *rel_paths* in the bundle."""
322+
323+ def find (manager , bundle ):
324+ return {
325+ DagFileInfo (rel_path = Path (rel_path ), bundle_name = bundle .name , bundle_path = bundle .path )
326+ for rel_path in rel_paths
327+ }
328+
329+ return find
330+
331+
320332class TestDagFileProcessorManager :
321333 @pytest .fixture (autouse = True )
322334 def _disable_examples (self ):
@@ -1700,7 +1712,10 @@ def test_a_callback_for_a_coordinator_file_is_dropped(
17001712
17011713 @mock .patch .object (FakeCoordinator , "parse_dag" , autospec = True )
17021714 @mock .patch .object (
1703- DagFileProcessorManager , "_find_files_in_bundle" , autospec = True , return_value = [Path ("good.native" )]
1715+ DagFileProcessorManager ,
1716+ "_find_files_in_bundle" ,
1717+ autospec = True ,
1718+ side_effect = _found_files ("good.native" ),
17041719 )
17051720 def test_coordinator_files_are_persisted (
17061721 self , mock_find_files , mock_parse_dag , tmp_path , configure_testing_dag_bundle
@@ -1734,7 +1749,7 @@ def reply(request, comms):
17341749 DagFileProcessorManager ,
17351750 "_find_files_in_bundle" ,
17361751 autospec = True ,
1737- return_value = [ Path ("garbage.native" ), Path ( "python_dag.py" )] ,
1752+ side_effect = _found_files ("garbage.native" , "python_dag.py" ),
17381753 )
17391754 def test_an_invalid_frame_does_not_stop_other_files_parsing (
17401755 self , mock_find_files , mock_parse_dag , tmp_path , configure_testing_dag_bundle
@@ -1767,7 +1782,10 @@ def reply(request, comms):
17671782 @mock .patch ("airflow.settings.get_dagbag_import_timeout" , autospec = True , return_value = 1 )
17681783 @mock .patch .object (FakeCoordinator , "parse_dag" , autospec = True )
17691784 @mock .patch .object (
1770- DagFileProcessorManager , "_find_files_in_bundle" , autospec = True , return_value = [Path ("slow.native" )]
1785+ DagFileProcessorManager ,
1786+ "_find_files_in_bundle" ,
1787+ autospec = True ,
1788+ side_effect = _found_files ("slow.native" ),
17711789 )
17721790 def test_a_coordinator_file_past_the_import_timeout_is_an_import_error (
17731791 self , mock_find_files , mock_parse_dag , mock_timeout , tmp_path , configure_testing_dag_bundle
@@ -1794,7 +1812,7 @@ def test_a_coordinator_file_past_the_import_timeout_is_an_import_error(
17941812 DagFileProcessorManager ,
17951813 "_find_files_in_bundle" ,
17961814 autospec = True ,
1797- return_value = [ Path ("broken.native" ), Path ( "python_dag.py" )] ,
1815+ side_effect = _found_files ("broken.native" , "python_dag.py" ),
17981816 )
17991817 def test_a_failing_import_timeout_policy_fails_only_its_file (
18001818 self , mock_find_files , mock_timeout , tmp_path , configure_testing_dag_bundle
0 commit comments