adiranjan25 commented on code in PR #76857:
URL: https://github.com/apache/airflow/pull/76857#discussion_r4534408374


##########
providers/amazon/tests/unit/amazon/aws/hooks/test_s3.py:
##########
@@ -1613,6 +1613,52 @@ def test_function(self, bucket_name=None):
                 "Expected provided bucket_name to take precedence over 
fallback"
             )
 
+    @pytest.mark.asyncio
+    async def test_provide_bucket_name_async(self):
+        """Async bucket resolution honors configuration and explicit 
overrides."""
+
+        class FakeS3Hook(S3Hook):
+            @provide_bucket_name
+            async def test_function(self, bucket_name=None):
+                return bucket_name
+
+        hook = FakeS3Hook(aws_conn_id="aws_default")
+        connection = Connection(
+            conn_id="aws_default",
+            conn_type="aws",
+            schema="schema-bucket",
+        )
+
+        with (
+            mock.patch(
+                "airflow.providers.amazon.aws.hooks.s3.get_async_connection",
+                new_callable=AsyncMock,
+                return_value=connection,
+            ) as mock_connection,
+            mock.patch(
+                "airflow.providers.amazon.aws.hooks.s3.get_async_extra_dejson",
+                new_callable=AsyncMock,
+                return_value={"service_config": {"s3": {"bucket_name": 
"configured-bucket"}}},
+            ) as mock_extras,
+        ):
+            assert await hook.test_function() == "configured-bucket"
+
+            mock_connection.reset_mock()
+            mock_extras.reset_mock()
+
+            assert await hook.test_function(bucket_name="explicit-bucket") == 
"explicit-bucket"
+            mock_connection.assert_not_awaited()
+            mock_extras.assert_not_awaited()
+
+            mock_extras.return_value = {}
+            assert await hook.test_function() == "schema-bucket"
+
+            connection.schema = None
+            assert await hook.test_function() is None
+
+        hook_without_connection = FakeS3Hook(aws_conn_id=None)
+        assert await hook_without_connection.test_function() is None

Review Comment:
   Thanks, @SameerMesiah97, for the helpful review.
   
   I've addressed both suggestions:
   
   - Moved the async mock patches to decorators above the test functions.
   - Parameterized the configured-bucket, schema-fallback, and no-config 
scenarios.
   - Added separate tests for explicit-bucket overrides and the 
no-connection-ID case.
   
   All five targeted tests pass, and Ruff lint and formatting checks are clean.
   
   The production implementation remains unchanged.
   
   I appreciate your feedback and would welcome another review when convenient.



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