uranusjr commented on a change in pull request #19102:
URL: https://github.com/apache/airflow/pull/19102#discussion_r735353850



##########
File path: tests/dag_processing/test_processor.py
##########
@@ -297,6 +297,34 @@ def test_dag_file_processor_sla_miss_email_exception(
         )
         
mock_stats_incr.assert_called_once_with('sla_email_notification_failure')
 
+    @mock.patch('airflow.dag_processing.processor.Stats.incr')
+    def test_dag_file_processor_sla_miss_stats_logging(self, mock_stats_incr, 
create_dummy_dag):
+        """Test that SLA misses are logged with the Stats framework"""
+        self.clean_db()

Review comment:
       This is automatically called after every test is run, so you don't need 
to call it in your test.

##########
File path: tests/dag_processing/test_processor.py
##########
@@ -297,6 +297,34 @@ def test_dag_file_processor_sla_miss_email_exception(
         )
         
mock_stats_incr.assert_called_once_with('sla_email_notification_failure')
 
+    @mock.patch('airflow.dag_processing.processor.Stats.incr')
+    def test_dag_file_processor_sla_miss_stats_logging(self, mock_stats_incr, 
create_dummy_dag):
+        """Test that SLA misses are logged with the Stats framework"""
+        self.clean_db()
+        test_start_date = days_ago(2, hour=0, minute=0)
+
+        with create_session() as session:
+            dag, task = create_dummy_dag(
+                dag_id='test_sla_miss_stats',
+                task_id='dummy',
+                schedule_interval="0 0 * * *",
+                catchup=True,
+                default_args={
+                    'start_date': test_start_date,
+                    'sla': datetime.timedelta(hours=1),
+                },
+            )

Review comment:
       ```suggestion
               dag, task = create_dummy_dag(
                   dag_id='test_sla_miss_stats',
                   task_id='dummy',
                   schedule_interval="0 0 * * *",
                   catchup=True,
                   default_args={
                       'start_date': test_start_date,
                       'sla': datetime.timedelta(hours=1),
                   },
                   session=session,
               )
   ```
   
   Since you created a session, it's best to reuse it across all calls. (Please 
also do this for other functions where applicable.)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to