def test_delete_dag_existing_file(self): # Test to check that the DAG should be deleted even if # the file containing it is not deleted DM = DagModel key = "my_dag_id" session = settings.Session() with tempfile.NamedTemporaryFile() as f: session.add(DM(dag_id=key, fileloc=f.name)) session.commit() dag_command.dag_delete(self.parser.parse_args(['dags', 'delete', key, '--yes'])) assert session.query(DM).filter_by(dag_id=key).count() == 0
def test_delete_dag(self): DM = DagModel key = "my_dag_id" session = settings.Session() session.add(DM(dag_id=key)) session.commit() dag_command.dag_delete(self.parser.parse_args(['dags', 'delete', key, '--yes'])) assert session.query(DM).filter_by(dag_id=key).count() == 0 with pytest.raises(AirflowException): dag_command.dag_delete( self.parser.parse_args(['dags', 'delete', 'does_not_exist_dag', '--yes']), )