@@ -858,7 +858,7 @@ def test_non_versioned_bundle_get_version_not_called(self):
858858 mybundle .refresh_interval = 0
859859 mybundle .supports_versioning = False
860860
861- with conf_vars ({("dag_bundles " , "config_list " ): json .dumps (config )}):
861+ with conf_vars ({("dag_processor " , "dag_bundle_config_list " ): json .dumps (config )}):
862862 DagBundlesManager ().sync_bundles_to_db ()
863863 with mock .patch (
864864 "airflow.dag_processing.bundles.manager.DagBundlesManager"
@@ -887,7 +887,7 @@ def test_versioned_bundle_get_version_called_once(self):
887887 mybundle .supports_versioning = True
888888 mybundle .get_current_version .return_value = "123"
889889
890- with conf_vars ({("dag_bundles " , "config_list " ): json .dumps (config )}):
890+ with conf_vars ({("dag_processor " , "dag_bundle_config_list " ): json .dumps (config )}):
891891 DagBundlesManager ().sync_bundles_to_db ()
892892 with mock .patch (
893893 "airflow.dag_processing.bundles.manager.DagBundlesManager"
@@ -899,5 +899,56 @@ def test_versioned_bundle_get_version_called_once(self):
899899
900900 # now run it again so we can check we only call get_current_version once
901901 mybundle .get_current_version .reset_mock ()
902+ mybundle .supports_versioning = True
902903 manager .run ()
903904 mybundle .get_current_version .assert_called_once ()
905+
906+ def test_no_longer_existing_bundle_doesnt_add_callack_to_queue (self , configure_testing_dag_bundle ):
907+ """Make sure that if a bundle is no longer available, we don't add a callback for the bundle"""
908+
909+ manager = DagFileProcessorManager (max_runs = 1 )
910+ callback = DagCallbackRequest (
911+ dag_id = "test_start_date_scheduling" ,
912+ bundle_name = "testing" ,
913+ filepath = "test_on_failure_callback_dag.py" ,
914+ is_failure_callback = True ,
915+ run_id = "123" ,
916+ )
917+ manager ._add_callback_to_queue (callback )
918+ # No callback added since the bundle is not configured
919+ assert manager ._file_path_queue == deque ()
920+ # let's configure a bundle
921+ with configure_testing_dag_bundle ("/tmp" ):
922+ manager = DagFileProcessorManager (max_runs = 1 )
923+ manager ._add_callback_to_queue (callback )
924+ # Now the callback should be added
925+ assert manager ._file_path_queue == deque (
926+ [
927+ DagFileInfo (
928+ bundle_name = "testing" ,
929+ path = "/tmp/test_on_failure_callback_dag.py" ,
930+ bundle_version = None ,
931+ )
932+ ]
933+ )
934+
935+ def test_callbacks_are_added_with_the_version_of_the_bundle (self , configure_testing_dag_bundle ):
936+ """Make sure that when we add a callback, we add the version of the bundle to the callback"""
937+ with configure_testing_dag_bundle ("/tmp" ):
938+ manager = DagFileProcessorManager (max_runs = 1 )
939+ callback = DagCallbackRequest (
940+ dag_id = "test_start_date_scheduling" ,
941+ bundle_name = "testing" ,
942+ filepath = "test_on_failure_callback_dag.py" ,
943+ is_failure_callback = True ,
944+ run_id = "123" ,
945+ bundle_version = "1" ,
946+ )
947+ manager ._add_callback_to_queue (callback )
948+ assert manager ._file_path_queue == deque (
949+ [
950+ DagFileInfo (
951+ bundle_name = "testing" , path = "/tmp/test_on_failure_callback_dag.py" , bundle_version = "1"
952+ )
953+ ]
954+ )
0 commit comments