Example DAG test (Airflow 1)

An example unit test for a DAG

Code sample

Python

To authenticate to Cloud Composer, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

def test_dag_with_variables(set_variables):
    # Importing the module verifies that there are no syntax errors.
    from . import unit_testing_variables as module

    # The assert_has_valid_dag verifies that the module contains an Airflow DAG
    # and that the DAG contains no cycles.
    internal_unit_testing.assert_has_valid_dag(module)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.