'Test if a a dagrun will not be scheduled if max_dag_runs has been reached'

def test_scheduler_verify_max_active_runs(self):

    dag = DAG(dag_id=u'test_scheduler_verify_max_active_runs', start_date=DEFAULT_DATE)
    dag.max_active_runs = 1
    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()
    session.close()
    scheduler = SchedulerJob()
    dag.clear()
    dr = scheduler.create_dag_run(dag)
    self.assertIsNotNone(dr)
    dr = scheduler.create_dag_run(dag)
    self.assertIsNone(dr)
