ferruzzi commented on code in PR #47527:
URL: https://github.com/apache/airflow/pull/47527#discussion_r1987978972


##########
providers/amazon/tests/unit/amazon/aws/triggers/test_mwaa.py:
##########
@@ -0,0 +1,108 @@
+# 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
+
+from unittest import mock
+from unittest.mock import AsyncMock
+
+import pytest
+
+from airflow.providers.amazon.aws.hooks.mwaa import MwaaHook
+from airflow.providers.amazon.aws.triggers.mwaa import 
MwaaDagRunCompletedTrigger
+from airflow.triggers.base import TriggerEvent
+from airflow.utils.state import DagRunState
+from unit.amazon.aws.utils.test_waiter import assert_expected_waiter_type
+
+BASE_TRIGGER_CLASSPATH = "airflow.providers.amazon.aws.triggers.mwaa."
+TRIGGER_KWARGS = {
+    "external_env_name": "test_env",
+    "external_dag_id": "test_dag",
+    "external_dag_run_id": "test_run_id",
+}
+
+
+class TestMwaaDagRunCompletedTrigger:
+    def test_init_states(self):
+        trigger = MwaaDagRunCompletedTrigger(**TRIGGER_KWARGS)
+        assert trigger.success_states == {DagRunState.SUCCESS.value}
+        assert trigger.failure_states == {DagRunState.FAILED.value}
+        acceptors = trigger.waiter_config_overrides["acceptors"]
+        expected_acceptors = [
+            {
+                "matcher": "path",
+                "argument": "RestApiResponse.state",
+                "expected": DagRunState.SUCCESS.value,
+                "state": "success",
+            },
+            {
+                "matcher": "path",
+                "argument": "RestApiResponse.state",
+                "expected": DagRunState.FAILED.value,
+                "state": "failure",
+            },
+            {
+                "matcher": "path",
+                "argument": "RestApiResponse.state",
+                "expected": DagRunState.RUNNING.value,
+                "state": "retry",
+            },
+            {
+                "matcher": "path",
+                "argument": "RestApiResponse.state",
+                "expected": DagRunState.QUEUED.value,
+                "state": "retry",
+            },
+        ]
+        assert len(acceptors) == len(DagRunState)
+        assert {tuple(sorted(a.items())) for a in acceptors} == {
+            tuple(sorted(a.items())) for a in expected_acceptors
+        }
+
+    def test_init_fail(self):
+        with pytest.raises(ValueError):

Review Comment:
   There was talk recently about requiring `with pytest.raises():` statements 
to include the `match` keyword to make sure the message is as expected and 
narrow down some unintended side-effects.  I'm not honestly sure where that 
discussion landed, but it might be a good idea to at least consider adding it 
either way.



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