kaxil commented on code in PR #71463:
URL: https://github.com/apache/airflow/pull/71463#discussion_r3766980591


##########
providers/anthropic/tests/unit/anthropic/operators/test_agent.py:
##########
@@ -98,7 +100,7 @@ def test_message_sends_user_message_and_waits(self, 
mock_hook_prop):
             "sess_1", {"type": "user.message", "content": [{"type": "text", 
"text": "summarize"}]}
         )
         hook.wait_for_session.assert_called_once()
-        context["ti"].xcom_push.assert_called_once_with(key="session_id", 
value="sess_1")
+        context["ti"].xcom_push.assert_any_call(key="session_id", 
value="sess_1")

Review Comment:
   Because this PR adds a second `xcom_push`. The task pushed only `session_id` 
before; it now pushes `usage` as well, so `assert_called_once_with` fails 
outright.
   
   Swapping to `assert_any_call` was the minimum fix but it quietly weakened 
the test -- it would pass no matter how many other pushes happened. Replaced 
with an assertion on the pushed keys in order:
   
   ```python
   assert [c.kwargs["key"] for c in context["ti"].xcom_push.call_args_list] == [
       "session_id",
       "usage",
   ]
   ```
   
   That pins exactly two pushes and their order, so it is stricter than what 
was there before this PR rather than looser. Thanks for pushing on it -- I had 
accepted the weaker assertion without noticing what it stopped checking.



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