@@ -1389,6 +1389,29 @@ def test_deactivate_stale_dags_marks_dags_in_inactive_bundles(self, session):
13891389 )
13901390 assert is_stale_by_dag == {"dag_in_inactive_bundle" : True , "dag_in_active_bundle" : False }
13911391
1392+ @pytest .mark .usefixtures ("testing_dag_bundle" )
1393+ def test_deactivate_stale_dags_matches_dags_nested_in_a_container (self , session ):
1394+ session .add (
1395+ DagModel (
1396+ dag_id = "nested_dag" ,
1397+ bundle_name = "testing" ,
1398+ relative_fileloc = "dags.zip/sub/nested_dag.py" ,
1399+ last_parsed_time = timezone .utcnow (),
1400+ is_stale = False ,
1401+ )
1402+ )
1403+ session .flush ()
1404+
1405+ manager = DagFileProcessorManager (max_runs = 1 , processor_timeout = 10 * 60 )
1406+ manager .deactivate_stale_dags (
1407+ last_parsed = {
1408+ DagFileInfo (rel_path = Path ("dags.zip" ), bundle_name = "testing" ): timezone .utcnow ()
1409+ + timedelta (hours = 1 )
1410+ }
1411+ )
1412+
1413+ assert session .scalar (select (DagModel .is_stale ).where (DagModel .dag_id == "nested_dag" ))
1414+
13921415 @pytest .mark .usefixtures ("testing_dag_bundle" )
13931416 def test_deactivate_stale_dags_marks_dags_with_null_bundle_name (self , session ):
13941417 """Dags carried over from Airflow 2.x keep a NULL bundle_name and must still be deactivated.
@@ -4192,8 +4215,8 @@ def test_refresh_dag_bundles_discovery_failure_keeps_known_files_and_dags(self):
41924215 ),
41934216 mock .patch .object (manager , "update_bundle_state" ),
41944217 mock .patch .object (manager , "_find_files_in_bundle" , side_effect = OSError ("listing failed" )),
4195- mock .patch .object (manager , "deactivate_deleted_dags" ) as mock_deactivate ,
4196- mock .patch .object (manager , "clear_orphaned_import_errors" ) as mock_clear ,
4218+ mock .patch .object (manager , "deactivate_deleted_dags" , autospec = True ) as mock_deactivate ,
4219+ mock .patch .object (manager , "clear_orphaned_import_errors" , autospec = True ) as mock_clear ,
41974220 mock .patch .object (manager , "handle_removed_files" ),
41984221 mock .patch .object (manager , "_resort_file_queue" ),
41994222 mock .patch .object (manager , "_add_new_files_to_queue" ),
0 commit comments