You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/04 09:00:00 UTC

[GitHub] [airflow] feluelle commented on a change in pull request #12096: add xcom push for ECSOperator

feluelle commented on a change in pull request #12096:
URL: https://github.com/apache/airflow/pull/12096#discussion_r551186185



##########
File path: tests/providers/amazon/aws/operators/test_ecs.py
##########
@@ -314,3 +314,22 @@ def test_reattach_successful(self, launch_type, tags, start_mock, check_mock, wa
         self.assertEqual(
             self.ecs.arn, 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55'
         )
+
+    @mock.patch.object(
+        ECSOperator, '_cloudwatch_log_events', return_value=[{"message": "Log output", "timestamp": 1000}]
+    )
+    def test_execute_xcom_with_log(self, _):
+        self.ecs.do_xcom_push = True
+        self.assertEqual(self.ecs.execute(None), "Log output")

Review comment:
       ```suggestion
       def test_execute_xcom_with_log(self, mock_cloudwatch_log_events):
           self.ecs.do_xcom_push = True
           log_message = self.ecs.execute(context=None)
           assert log_message == mock_cloudwatch_log_events.return_value[0]['message']
   ```
   WDYT? :)

##########
File path: tests/providers/amazon/aws/operators/test_ecs.py
##########
@@ -314,3 +314,22 @@ def test_reattach_successful(self, launch_type, tags, start_mock, check_mock, wa
         self.assertEqual(
             self.ecs.arn, 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55'
         )
+
+    @mock.patch.object(
+        ECSOperator, '_cloudwatch_log_events', return_value=[{"message": "Log output", "timestamp": 1000}]
+    )
+    def test_execute_xcom_with_log(self, _):
+        self.ecs.do_xcom_push = True
+        self.assertEqual(self.ecs.execute(None), "Log output")
+
+    @mock.patch.object(ECSOperator, '_cloudwatch_log_events', return_value=[])
+    def test_execute_xcom_with_no_log(self, _):
+        self.ecs.do_xcom_push = True
+        self.assertEqual(self.ecs.execute(None), None)

Review comment:
       Same here.

##########
File path: tests/providers/amazon/aws/operators/test_ecs.py
##########
@@ -314,3 +314,22 @@ def test_reattach_successful(self, launch_type, tags, start_mock, check_mock, wa
         self.assertEqual(
             self.ecs.arn, 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55'
         )
+
+    @mock.patch.object(
+        ECSOperator, '_cloudwatch_log_events', return_value=[{"message": "Log output", "timestamp": 1000}]
+    )
+    def test_execute_xcom_with_log(self, _):
+        self.ecs.do_xcom_push = True
+        self.assertEqual(self.ecs.execute(None), "Log output")
+
+    @mock.patch.object(ECSOperator, '_cloudwatch_log_events', return_value=[])
+    def test_execute_xcom_with_no_log(self, _):
+        self.ecs.do_xcom_push = True
+        self.assertEqual(self.ecs.execute(None), None)
+
+    @mock.patch.object(
+        ECSOperator, '_cloudwatch_log_events', return_value=[{"message": "Log output", "timestamp": 1000}]
+    )
+    def test_execute_xcom_disabled(self, _):
+        self.ecs.do_xcom_push = False
+        self.assertEqual(self.ecs.execute(None), None)

Review comment:
       And here.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org