dabla commented on code in PR #76855:
URL: https://github.com/apache/airflow/pull/76855#discussion_r4529250378


##########
providers/amazon/tests/unit/amazon/aws/hooks/test_s3.py:
##########
@@ -678,6 +678,19 @@ async def 
test_s3_key_hook_get_file_metadata_async_when_requester_pays_is(self,
             **extra_params,
         )
 
+    @pytest.mark.asyncio
+    async def test_get_head_object_async_does_not_print_to_stdout(self, 
capsys):
+        """Async S3 calls must not emit debug output to stdout."""
+        hook = S3Hook(aws_conn_id=None)
+        client = AsyncMock()
+        client.head_object.return_value = {"ContentLength": 10}
+
+        result = await hook.get_head_object_async(client, "test-key", 
"test-bucket")
+
+        assert result == {"ContentLength": 10}

Review Comment:
   **[nit]** Assert the arguments of the call, not only that it happened.
   
   The PR says the change keeps the decorator's behaviour, and this test goes 
through both `unify_bucket_name_and_key` and the coroutine branch of 
`provide_bucket_name`, so it can check that cheaply:
   
   ```python
   client.head_object.assert_awaited_once_with(Bucket="test-bucket", 
Key="test-key")
   ```



##########
providers/amazon/tests/unit/amazon/aws/hooks/test_s3.py:
##########
@@ -678,6 +678,19 @@ async def 
test_s3_key_hook_get_file_metadata_async_when_requester_pays_is(self,
             **extra_params,
         )
 
+    @pytest.mark.asyncio
+    async def test_get_head_object_async_does_not_print_to_stdout(self, 
capsys):
+        """Async S3 calls must not emit debug output to stdout."""
+        hook = S3Hook(aws_conn_id=None)
+        client = AsyncMock()

Review Comment:
   **[nit]** Give the mock a spec.
   
   [AGENTS.md](https://github.com/apache/airflow/blob/main/AGENTS.md) asks for 
`spec`/`autospec` when mocking. A bare `AsyncMock()` accepts any attribute, so 
a typo such as `client.head_objects` would still pass. The `aload_bytes` tests 
further down in this file already use a small spec class for exactly this 
client; something like this is enough here:
   
   ```python
   client = AsyncMock(spec=["head_object"])
   ```



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