-
|
Hey all, so our team was using airflow say this test class Test_HEPCreateDAG:
dag = dagbag.get_dag("hep_create_dag")
context = {
"dag_run": {"run_id": "test_run"},
"ti": {"xcom_push": lambda key, value: None},
"params": {"workflow_id": "00000000-0000-0000-0000-000000001111"},
}
def test_set_schema(self):
task = self.dag.get_task("set_schema")
result = task.execute(context={})where this set_schema task does something like: from airflow.sdk.bases.hook import BaseHook
@task
def set_schema(**context):
conn = BaseHook.get_connection("my_connection")would work but now it fails with So I am wondering, how do you guys test tasks that require accessing connections? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Mocking described in |
Beta Was this translation helpful? Give feedback.
Mocking described in
https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html#mocking-variables-and-connections
works quite well