You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "syedahsn (via GitHub)" <gi...@apache.org> on 2023/06/07 03:26:11 UTC

[GitHub] [airflow] syedahsn commented on a diff in pull request #30928: Add Deferrable mode to Emr Add Steps operator

syedahsn commented on code in PR #30928:
URL: https://github.com/apache/airflow/pull/30928#discussion_r1220776587


##########
tests/providers/amazon/aws/triggers/test_emr_trigger.py:
##########
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import sys
+
+import pytest
+
+from airflow.providers.amazon.aws.triggers.emr import EmrAddStepsTrigger
+from airflow.triggers.base import TriggerEvent
+
+if sys.version_info < (3, 8):
+    from asynctest import CoroutineMock as AsyncMock, mock as async_mock
+else:
+    from unittest import mock as async_mock
+    from unittest.mock import AsyncMock
+
+TEST_JOB_FLOW_ID = "test_job_flow_id"
+TEST_STEP_IDS = ["step1", "step2"]
+TEST_AWS_CONN_ID = "test-aws-id"
+TEST_MAX_ATTEMPT = 10
+TEST_POLL_INTERVAL = 10
+
+
+class TestEmrAddStepsTrigger:
+    def test_emr_add_steps_trigger_serialize(self):
+        emr_add_steps_trigger = EmrAddStepsTrigger(
+            job_flow_id=TEST_JOB_FLOW_ID,
+            step_ids=TEST_STEP_IDS,
+            aws_conn_id=TEST_AWS_CONN_ID,
+            max_attempts=TEST_MAX_ATTEMPT,
+            poll_interval=TEST_POLL_INTERVAL,
+        )
+        class_path, args = emr_add_steps_trigger.serialize()
+        assert class_path == "airflow.providers.amazon.aws.triggers.emr.EmrAddStepsTrigger"
+        assert args["job_flow_id"] == TEST_JOB_FLOW_ID
+        assert args["step_ids"] == TEST_STEP_IDS
+        assert args["poll_interval"] == str(TEST_POLL_INTERVAL)
+        assert args["max_attempts"] == str(TEST_MAX_ATTEMPT)
+        assert args["aws_conn_id"] == TEST_AWS_CONN_ID

Review Comment:
   I understand what you are saying, and I definitely agree with your idea. But as far as I am aware, we don't have simple a way to do this. This test is still _somewhat_ useful because it catches mistakes related to parsing because the `serialize` method converts everything to `str`, and that needs to be taken into account when using these parameters in the `run` method. 



-- 
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: commits-unsubscribe@airflow.apache.org

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