Created
August 9, 2018 11:03
-
-
Save chandulal/6f6ff5a6f8fc96331c28f391e06668ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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