@@ -790,5 +790,38 @@ def test_start_date_filter(self):
790
790
self .assertEqual (resp .status_code , 200 )
791
791
792
792
793
+ class TestDeleteDag (unittest .TestCase ):
794
+
795
+ def setUp (self ):
796
+ conf .load_test_config ()
797
+ app = application .create_app (testing = True )
798
+ app .config ['WTF_CSRF_METHODS' ] = []
799
+ self .app = app .test_client ()
800
+
801
+ def test_delete_dag_button_normal (self ):
802
+ resp = self .app .get ('/' , follow_redirects = True )
803
+ self .assertIn ('/delete?dag_id=example_bash_operator' , resp .data .decode ('utf-8' ))
804
+ self .assertIn ("return confirmDeleteDag('example_bash_operator')" , resp .data .decode ('utf-8' ))
805
+
806
+ def test_delete_dag_button_for_dag_on_scheduler_only (self ):
807
+ # Test for JIRA AIRFLOW-3233 (PR 4069):
808
+ # The delete-dag URL should be generated correctly for DAGs
809
+ # that exist on the scheduler (DB) but not the webserver DagBag
810
+
811
+ test_dag_id = "non_existent_dag"
812
+
813
+ session = Session ()
814
+ DM = models .DagModel
815
+ session .query (DM ).filter (DM .dag_id == 'example_bash_operator' ).update ({'dag_id' : test_dag_id })
816
+ session .commit ()
817
+
818
+ resp = self .app .get ('/' , follow_redirects = True )
819
+ self .assertIn ('/delete?dag_id={}' .format (test_dag_id ), resp .data .decode ('utf-8' ))
820
+ self .assertIn ("return confirmDeleteDag('{}')" .format (test_dag_id ), resp .data .decode ('utf-8' ))
821
+
822
+ session .query (DM ).filter (DM .dag_id == test_dag_id ).update ({'dag_id' : 'example_bash_operator' })
823
+ session .commit ()
824
+
825
+
793
826
if __name__ == '__main__' :
794
827
unittest .main ()
0 commit comments