potiuk commented on code in PR #72472:
URL: https://github.com/apache/airflow/pull/72472#discussion_r4057161450


##########
providers/amazon/tests/unit/amazon/aws/triggers/test_opensearch_serverless.py:
##########
@@ -48,31 +48,64 @@ class TestOpenSearchServerlessCollectionActiveTrigger:
     COLLECTION_ID = "test_collection_id"
 
     @pytest.mark.parametrize(
-        ("collection_name", "collection_id", "expected_pass"),
+        ("collection_name", "collection_id"),
         [
-            pytest.param(COLLECTION_NAME, COLLECTION_ID, False, 
id="both_provided_fails"),
-            pytest.param(COLLECTION_NAME, None, True, 
id="only_name_provided_passes"),
-            pytest.param(None, COLLECTION_ID, True, 
id="only_id_provided_passes"),
+            pytest.param(COLLECTION_NAME, None, id="collection_name"),
+            pytest.param(None, COLLECTION_ID, id="collection_id"),
         ],
     )
-    def test_serialization(self, collection_name, collection_id, 
expected_pass):
-        """Assert that arguments and classpath are correctly serialized."""
-        call_args = prune_dict({"collection_id": collection_id, 
"collection_name": collection_name})
-
-        if expected_pass:
-            trigger = OpenSearchServerlessCollectionActiveTrigger(**call_args)
-            classpath, kwargs = trigger.serialize()
-            assert classpath == BASE_TRIGGER_CLASSPATH + 
"OpenSearchServerlessCollectionActiveTrigger"
-            if call_args.get("collection_name"):
-                assert kwargs.get("collection_name") == self.COLLECTION_NAME
-            if call_args.get("collection_id"):
-                assert kwargs.get("collection_id") == self.COLLECTION_ID
-
-        if not expected_pass:
-            with pytest.raises(
-                AttributeError, match="Either collection_ids or 
collection_names must be provided, not both."
-            ):
-                OpenSearchServerlessCollectionActiveTrigger(**call_args)
+    def test_serialization_round_trip(self, collection_name, collection_id):
+        """Assert that all arguments survive serialization and 
reconstruction."""
+        trigger = OpenSearchServerlessCollectionActiveTrigger(
+            **prune_dict({"collection_id": collection_id, "collection_name": 
collection_name}),
+            aws_conn_id="test_conn",
+            region_name="eu-west-1",
+            verify=False,
+            botocore_config={"read_timeout": 42},
+        )
+
+        classpath, kwargs = trigger.serialize()
+
+        assert classpath == BASE_TRIGGER_CLASSPATH + 
"OpenSearchServerlessCollectionActiveTrigger"
+        assert kwargs == {
+            "collection_id": collection_id,
+            "collection_name": collection_name,
+            "waiter_delay": 60,
+            "waiter_max_attempts": 20,
+            "aws_conn_id": "test_conn",
+            "region_name": "eu-west-1",
+            "verify": False,
+            "botocore_config": {"read_timeout": 42},
+        }
+        restored_trigger = 
OpenSearchServerlessCollectionActiveTrigger(**kwargs)
+        assert restored_trigger.serialize() == (classpath, kwargs)
+
+    def test_both_collection_name_and_id_raise(self):
+        with pytest.raises(
+            AttributeError, match="Either collection_ids or collection_names 
must be provided, not both."
+        ):
+            OpenSearchServerlessCollectionActiveTrigger(
+                collection_name=self.COLLECTION_NAME, 
collection_id=self.COLLECTION_ID
+            )
+
+    @mock.patch(BASE_TRIGGER_CLASSPATH + "OpenSearchServerlessHook")

Review Comment:
   `autospec=True` here would make a kwarg-name typo (e.g. `botocore_config=` 
instead of `config=`) fail at the call instead of being swallowed by the mock. 
Optional; neighbouring trigger tests have the same omission (fixup incoming).



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