'Test if a a dagrun wil be set failed if timeout'

def test_scheduler_fail_dagrun_timeout(self):

    dag = DAG(dag_id=u'test_scheduler_fail_dagrun_timeout', start_date=DEFAULT_DATE)
    dag.dagrun_timeout = datetime.timedelta(seconds=60)
    dag_task1 = DummyOperator(task_id=u'dummy', dag=dag, owner=u'airflow')
    session = settings.Session()
    orm_dag = DagModel(dag_id=dag.dag_id)
    session.merge(orm_dag)
    session.commit()
    scheduler = SchedulerJob()
    dag.clear()
    dr = scheduler.create_dag_run(dag)
    self.assertIsNotNone(dr)
    dr.start_date = (datetime.datetime.now() - datetime.timedelta(days=1))
    session.merge(dr)
    session.commit()
    dr2 = scheduler.create_dag_run(dag)
    self.assertIsNotNone(dr2)
    dr.refresh_from_db(session=session)
    self.assertEquals(dr.state, State.FAILED)
