)
        runs = DagRun.next_dagruns_to_examine(state, session).all()
        assert runs == [dr]
        orm_dag.is_paused = True
        session.flush()
        runs = DagRun.next_dagruns_to_examine(state, session).all()
        assert runs == []
    @mock.patch.object(Stats, "timing")
    def test_no_scheduling_delay_for_nonscheduled_runs(self, stats_mock, session):
        """
        Tests that dag scheduling delay stat is not called if the dagrun is not a scheduled run.
        This case is manual run. Simple test for coherence check.
        """
        dag = DAG(dag_id="test_dagrun_stats", start_date=DEFAULT_DATE)
        dag_task = EmptyOperator(task_id="dummy", dag=dag)
        initial_task_states = {
            dag_task.task_id: TaskInstanceState.SUCCESS,
        }
        dag_run = self.create_dag_run(dag=dag, task_states=initial_task_states, session=session)
        dag_run.update_state()
        assert call(f"dagrun.{dag.dag_id}.first_task_scheduling_delay") not in stats_mock.mock_calls
    @pytest.mark.parametrize(
        "schedule_interval, expected",
        [
            ("*/5 * * * *", True),
            (None, False),
            ("@once", False),
        ],
    )
    def test_emit_scheduling_delay(self, session, schedule_interval, expected):