vincbeck commented on code in PR #41554:
URL: https://github.com/apache/airflow/pull/41554#discussion_r1723383044
##########
tests/providers/openai/operators/test_openai.py:
##########
@@ -48,3 +51,55 @@ def test_execute_with_invalid_input(invalid_input):
context = Context()
with pytest.raises(ValueError):
operator.execute(context)
+
+
+def test_openai_trigger_batch_operator():
+ operator = OpenAITriggerBatchOperator(
+ task_id="TaskId",
+ conn_id="test_conn_id",
+ file_id="file_id",
+ endpoint="/v1/chat/completions",
+ )
+ mock_batch = Batch(
+ id="batch_id",
+ object="batch",
+ completion_window="24h",
+ created_at=1699061776,
+ endpoint="/v1/chat/completions",
+ input_file_id="file_id",
+ status="completed",
+ )
+ mock_hook_instance = Mock()
+ mock_hook_instance.get_batch.return_value = mock_batch
+ mock_hook_instance.create_batch.return_value = mock_batch
+ operator.hook = mock_hook_instance
+
+ context = Context()
+ batch_id = operator.execute(context)
+ assert batch_id == "batch_id"
+
+
+def test_openai_trigger_batch_operator_with_deferred():
Review Comment:
Maybe add a test with `wait_for_completion=False`?
--
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]