Copilot commented on code in PR #64360:
URL: https://github.com/apache/airflow/pull/64360#discussion_r3025328821


##########
providers/google/tests/unit/google/cloud/operators/test_gen_ai.py:
##########
@@ -1092,3 +1092,13 @@ def 
test_execute_client_error_raises_airflow_exception(self, mock_hook):
         mock_hook.return_value.delete_file.assert_called_once_with(
             file_name=TEST_FILE_NAME,
         )
+
+    def test_count_tokens_invalid_project_id(self):
+        op = GenAICountTokensOperator(
+            task_id="test",
+            project_id=None,
+            location="us-central1",
+        )
+
+        with pytest.raises(AirflowException):
+            op.execute(context={"ti": mock.MagicMock()})

Review Comment:
   This test constructs `GenAICountTokensOperator` without required args 
(`contents` and `model`), so it will fail at instantiation with `TypeError` 
rather than raising `AirflowException` from `execute()`. Also, the test doesn’t 
patch `GenAIGenerativeModelHook`, so `execute()` would attempt to instantiate a 
real hook/client (making the unit test flaky if it ever reached that point). 
Consider moving this into `TestGenAICountTokensOperator`, pass the required 
params, and mock the hook/client; if the intent is to validate `project_id` 
being missing, assert the specific exception/message that is actually raised 
for that condition (or add explicit operator validation and test that behavior).



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