AchimGaedkeLynker opened a new issue, #52862:
URL: https://github.com/apache/airflow/issues/52862

   ### What do you see as an issue?
   
   I copied the code from 
https://airflow.apache.org/docs/apache-airflow/3.0.2/best-practices.html#testing-a-dag
 section "Unit test for custom operator" and found out that the DAG class 
instance was missing the method `create_dagrun`
   
   ```text
   dag = <DAG: my_custom_operator_dag>
   
       def test_my_custom_operator_execute_no_trigger(dag):
   >       dagrun = dag.create_dagrun(
                    ^^^^^^^^^^^^^^^^^
               run_id=TEST_RUN_ID,
               logical_date=DATA_INTERVAL_START,
               data_interval=(DATA_INTERVAL_START, DATA_INTERVAL_END),
               run_type=DagRunType.MANUAL,
               triggered_by=DagRunTriggeredByType.TIMETABLE,
               state=DagRunState.RUNNING,
               start_date=DATA_INTERVAL_END,
           )
   E       AttributeError: 'DAG' object has no attribute 'create_dagrun'
   
   airflow_conda_operator/tests/test_operators.py:43: AttributeError
   ```
   
   ### Solving the problem
   
   after some desperate googling, I thought I'll give it a try and import `DAG` 
the old way:
   
   ```python
   from airflow import DAG
   ````
   
   and e voilĂ , it worked.
   
   
   ### Anything else
   
   Would you agree, this is a documentation error?
   
   (Alternatively, this could be a coding error and the SDK DAG definition 
requires a `create_dagrun` method).
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to