Recall & Review
beginner
What is the main goal of unit testing DAGs in Airflow?
To verify that individual parts of the DAG, like tasks and dependencies, work correctly without running the entire workflow.
Click to reveal answer
beginner
Which Python module is commonly used to write unit tests for Airflow DAGs?
The
unittest module is commonly used for writing unit tests in Python, including for Airflow DAGs.Click to reveal answer
intermediate
How can you check if all tasks in a DAG are correctly defined in a unit test?
By asserting the presence of expected task IDs in the DAG's
task_ids set during the test.Click to reveal answer
intermediate
Why should unit tests for DAGs avoid running actual task logic?
Because unit tests focus on structure and configuration, not execution. Running tasks can be slow and cause side effects.
Click to reveal answer
intermediate
What is a simple way to test task dependencies in an Airflow DAG?
Check the
upstream_task_ids and downstream_task_ids properties of tasks to confirm correct order.Click to reveal answer
What does a unit test for an Airflow DAG usually verify?
✗ Incorrect
Unit tests focus on checking task definitions and dependencies, not running the full workflow.
Which Python feature helps isolate DAG tests from actual task execution?
✗ Incorrect
Mocking replaces real task execution with fake calls to test structure without side effects.
How do you access all tasks in an Airflow DAG object?
✗ Incorrect
The
tasks attribute of a DAG holds all task objects.What is a common Python testing framework used with Airflow DAGs?
✗ Incorrect
unittest is a built-in Python framework often used for testing Airflow DAGs.Why avoid running actual tasks in DAG unit tests?
✗ Incorrect
Running tasks can be slow and cause unwanted effects; unit tests should be quick and isolated.
Explain how you would write a unit test to verify task dependencies in an Airflow DAG.
Think about how tasks connect to each other in the DAG.
You got /3 concepts.
Describe why mocking is useful when unit testing Airflow DAGs.
Consider what happens if tasks run during tests.
You got /4 concepts.