You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@airflow.apache.org by Lewis John McGibbney <le...@apache.org> on 2021/08/04 14:09:44 UTC
Re: Guidance/best practice for mocking task instance output for unit testing DAGs
Hi users@,
Is anyone able to assist here? Does my example make sense?
Thank you
lewismc
On 2021/07/29 16:39:02, Lewis John McGibbney <le...@apache.org> wrote:
> Hi users@,
> Say I want to unit test Task A which accepts one or more parameters. These parameters are the outputs of some other task which I want to mock. Can someone provide a code example of how I would do that?
> We are using pytest as opposed to unittest but an example of either would be greatly appreciated.
> I studied several articles [0] [1] [2] which were informative but I think lack the content which explains what I want to do above.
> I did find the following code example [3] which I feel is on the correct track but I am not confident.
> Thanks for any consideration.
> lewismc
>
> [0] https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html#testing-a-dag
> [1] https://blog.usejournal.com/testing-in-airflow-part-1-dag-validation-tests-dag-definition-tests-and-unit-tests-2aa94970570c
> [2] https://medium.com/@chandukavar/testing-in-airflow-part-2-integration-tests-and-end-to-end-pipeline-tests-af0555cd1a82
> [3] https://github.com/apache/airflow/blob/main/tests/ti_deps/deps/test_dagrun_exists_dep.py
>