diff --git a/src/google/adk/a2a/converters/test_EventConverterConvertA2ATaskToEvent.py b/src/google/adk/a2a/converters/test_EventConverterConvertA2ATaskToEvent.py new file mode 100644 index 0000000000..bd6f7adc91 --- /dev/null +++ b/src/google/adk/a2a/converters/test_EventConverterConvertA2ATaskToEvent.py @@ -0,0 +1,121 @@ +# ********RoostGPT******** +""" +Test generated by RoostGPT for test unit-adk-python using AI Type Azure Open AI and AI Model gpt-5 + +ROOST_METHOD_HASH=convert_a2a_task_to_event_40cb3ce258 +ROOST_METHOD_SIG_HASH=convert_a2a_task_to_event_124ed678ea + + +Scenario 1: Rejects None Task Input +Details: + TestName: test_none_task_raises_value_error + Description: Verifies that passing None as a2a_task raises ValueError, enforcing required input. +Execution: + Arrange: No setup needed beyond preparing a None task reference. + Act: Call convert_a2a_task_to_event(a2a_task=None). + Assert: Expect ValueError with message "A2A task cannot be None". +Validation: + Ensures input validation is enforced as specified, preventing undefined behavior and aligning with the function’s documented contract. + +""" + +# ********RoostGPT******** +from __future__ import annotations + +import importlib +import logging +import sys +import unittest +import uuid +from collections.abc import Callable +from datetime import datetime, timezone +from typing import Any, Dict, List, Optional + +# Third-party or project-specific imports that may or may not exist in the environment. +# These imports are included to align with the provided instructions. +try: + A2AEvent = importlib.import_module("a2a.server.events") +except Exception: # pragma: no cover + A2AEvent = None + +try: + # Attempt to import selected types; if unavailable, proceed as tests don't depend on them directly. + from a2a.types import DataPart, Message, Role, Task, TaskState, TaskStatus, TaskStatusUpdateEvent, TextPart +except Exception: # pragma: no cover + DataPart = Message = Role = Task = TaskState = TaskStatus = TaskStatusUpdateEvent = TextPart = None # type: ignore[assignment] + +try: + genai_types = importlib.import_module("google.genai") +except Exception: # pragma: no cover + genai_types = None + +try: + InvocationContext = importlib.import_module("agents.invocation_context").InvocationContext # type: ignore[attr-defined] +except Exception: # pragma: no cover + InvocationContext = None # type: ignore[assignment] + +try: + Event = importlib.import_module("events.event").Event # type: ignore[attr-defined] +except Exception: # pragma: no cover + Event = None # type: ignore[assignment] + +try: + REQUEST_EUC_FUNCTION_CALL_NAME = importlib.import_module("flows.llm_flows.functions").REQUEST_EUC_FUNCTION_CALL_NAME # type: ignore[attr-defined] +except Exception: # pragma: no cover + REQUEST_EUC_FUNCTION_CALL_NAME = None # type: ignore[assignment] + +try: + a2a_experimental = importlib.import_module("experimental.a2a_experimental") # type: ignore[attr-defined] +except Exception: # pragma: no cover + a2a_experimental = None # type: ignore[assignment] + +try: + from part_converter import ( + A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY, + A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL, + A2A_DATA_PART_METADATA_TYPE_KEY, + A2APartToGenAIPartConverter, + convert_a2a_part_to_genai_part, + convert_genai_part_to_a2a_part, + GenAIPartToA2APartConverter, + ) +except Exception: # pragma: no cover + A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY = None # type: ignore[assignment] + A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL = None # type: ignore[assignment] + A2A_DATA_PART_METADATA_TYPE_KEY = None # type: ignore[assignment] + A2APartToGenAIPartConverter = None # type: ignore[assignment] + convert_a2a_part_to_genai_part = None # type: ignore[assignment] + convert_genai_part_to_a2a_part = None # type: ignore[assignment] + GenAIPartToA2APartConverter = None # type: ignore[assignment] + +try: + _get_adk_metadata_key = importlib.import_module("utils")._get_adk_metadata_key # type: ignore[attr-defined] +except Exception: # pragma: no cover + _get_adk_metadata_key = None # type: ignore[assignment] + +# Import the function under test as requested. +from src.google.adk.a2a.converters.event_converter import convert_a2a_task_to_event + + +def tag(*labels: str): + """Simple decorator to attach tags to test methods.""" + def decorator(func): + setattr(func, "tags", labels) + return func + return decorator + + +class Test_EventConverterConvertA2ATaskToEvent(unittest.TestCase): + @tag("smoke", "regression", "negative", "invalid") + def test_none_task_raises_value_error(self): + # Arrange + a2a_task = None + + # Act / Assert + with self.assertRaisesRegex(ValueError, r"^A2A task cannot be None$"): + convert_a2a_task_to_event(a2a_task=a2a_task) + + +if __name__ == "__main__": + # TODO: Adjust verbosity if needed for your test environment + unittest.main(verbosity=2) diff --git a/src/google/adk/a2a/requirements-roost.txt b/src/google/adk/a2a/requirements-roost.txt new file mode 100644 index 0000000000..d18d252c77 --- /dev/null +++ b/src/google/adk/a2a/requirements-roost.txt @@ -0,0 +1,15 @@ + +agents +artifacts +auth +events +flows +memory +protobuf +pydantic +runners +starlette +tools +typing_extensions +pytest +auto_mix_prep \ No newline at end of file