From 89cd90f7946fa8090d6b6336060f7393283883fd Mon Sep 17 00:00:00 2001 From: DonHaul Date: Thu, 19 Dec 2024 16:55:45 +0100 Subject: [PATCH] workflows: add testing to wf callback failure * ref: cern-sis/issues-inspire/issues/643 --- .../author_create/author_create_rejected.py | 1 + workflows/tests/test_dags_integrity.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/workflows/dags/author/author_create/author_create_rejected.py b/workflows/dags/author/author_create/author_create_rejected.py index 1938e1c9c..d761c1691 100644 --- a/workflows/dags/author/author_create/author_create_rejected.py +++ b/workflows/dags/author/author_create/author_create_rejected.py @@ -15,6 +15,7 @@ params={ "workflow_id": Param(type="string", default=""), "data": Param(type="object", default={}), + "collection": Param(type="string", default=AUTHORS), }, start_date=datetime.datetime(2024, 5, 5), schedule=None, diff --git a/workflows/tests/test_dags_integrity.py b/workflows/tests/test_dags_integrity.py index 86d1b16d2..6832fda84 100644 --- a/workflows/tests/test_dags_integrity.py +++ b/workflows/tests/test_dags_integrity.py @@ -1,6 +1,17 @@ from airflow.models import DagBag -def test_dagbag(): +class TestDagsIntegrity: dag_bag = DagBag(include_examples=False) - assert not dag_bag.import_errors + + def test_dagbag(self): + assert not self.dag_bag.import_errors + + def test_on_failure_callback(self): + for dag_id, dag in self.dag_bag.dags.items(): + if ( + dag.__dict__.get("on_failure_callback") + and dag.__dict__.get("on_failure_callback").__name__ + == "set_workflow_status_to_error" + ): + assert "collection" in dag.__dict__["params"], dag_id