Skip to content

Instantly share code, notes, and snippets.

@chandulal
Created August 9, 2018 11:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chandulal/6f6ff5a6f8fc96331c28f391e06668ac to your computer and use it in GitHub Desktop.
Save chandulal/6f6ff5a6f8fc96331c28f391e06668ac to your computer and use it in GitHub Desktop.
import unittest
from airflow.models import DagBag
class TestDagIntegrity(unittest.TestCase):
LOAD_SECOND_THRESHOLD = 2
def setUp(self):
self.dagbag = DagBag()
def test_import_dags(self):
self.assertFalse(
len(self.dagbag.import_errors),
'DAG import failures. Errors: {}'.format(
self.dagbag.import_errors
)
)
def test_alert_email_present(self):
for dag_id, dag in self.dagbag.dags.iteritems():
emails = dag.default_args.get('email', [])
msg = 'Alert email not set for DAG {id}'.format(id=dag_id)
self.assertIn('alert.email@gmail.com', emails, msg)
suite = unittest.TestLoader().loadTestsFromTestCase(TestDagIntegrity)
unittest.TextTestRunner(verbosity=2).run(suite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment