Add comprehensive tests for various components in the agentflow.storage and publisher modulesre#131
Open
Iamsdt wants to merge 1 commit into
Open
Add comprehensive tests for various components in the agentflow.storage and publisher modulesre#131Iamsdt wants to merge 1 commit into
Iamsdt wants to merge 1 commit into
Conversation
Iamsdt
commented
Jun 10, 2026
Collaborator
- Enhance test coverage for agent retry fallback with additional cases for non-integer and None status codes.
- Introduce tests for CompositePublisher lifecycle, including adding, publishing, and removing publishers.
- Implement tests for KafkaPublisher and RabbitMQPublisher to handle closed states and error scenarios.
- Add tests for publishing events and managing background tasks.
- Create a ConcreteMediaStore for testing media storage functionalities, including metadata retrieval and existence checks.
- Extend MediaRefResolver tests to cover legacy reference handling and transport modes.
- Implement ProviderMediaCache tests to validate caching behavior and eviction logic.
- Add tests for Google and OpenAI API call implementations to ensure correct parameter handling and response processing.
…ge and publisher modules - Enhance test coverage for agent retry fallback with additional cases for non-integer and None status codes. - Introduce tests for CompositePublisher lifecycle, including adding, publishing, and removing publishers. - Implement tests for KafkaPublisher and RabbitMQPublisher to handle closed states and error scenarios. - Add tests for publishing events and managing background tasks. - Create a ConcreteMediaStore for testing media storage functionalities, including metadata retrieval and existence checks. - Extend MediaRefResolver tests to cover legacy reference handling and transport modes. - Implement ProviderMediaCache tests to validate caching behavior and eviction logic. - Add tests for Google and OpenAI API call implementations to ensure correct parameter handling and response processing.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Comment on lines
+15
to
+36
| # def missing_a2a_sdk_error(feature: str, exc: BaseException) -> RuntimeError: | ||
| # """Return a consistent error for A2A helpers when a2a-sdk is absent.""" | ||
| # return RuntimeError( | ||
| # f"{feature} requires the optional 'a2a-sdk' package. {A2A_EXTRA_INSTALL_HINT}" | ||
| # ) | ||
|
|
||
|
|
||
| def import_a2a_module(module_name: str, feature: str) -> ModuleType: | ||
| """Import an A2A SDK module with a helpful optional-dependency error.""" | ||
| try: | ||
| return import_module(module_name) | ||
| except Exception as exc: | ||
| raise missing_a2a_sdk_error(feature, exc) from exc | ||
| # def import_a2a_module(module_name: str, feature: str) -> ModuleType: | ||
| # """Import an A2A SDK module with a helpful optional-dependency error.""" | ||
| # try: | ||
| # return import_module(module_name) | ||
| # except Exception as exc: | ||
| # raise missing_a2a_sdk_error(feature, exc) from exc | ||
|
|
||
|
|
||
| def get_a2a_attr(module_name: str, attr_name: str, feature: str) -> Any: | ||
| """Get an attribute from an A2A SDK module with a consistent error.""" | ||
| module = import_a2a_module(module_name, feature) | ||
| try: | ||
| return getattr(module, attr_name) | ||
| except AttributeError as exc: | ||
| raise missing_a2a_sdk_error(feature, exc) from exc | ||
| # def get_a2a_attr(module_name: str, attr_name: str, feature: str) -> Any: | ||
| # """Get an attribute from an A2A SDK module with a consistent error.""" | ||
| # module = import_a2a_module(module_name, feature) | ||
| # try: | ||
| # return getattr(module, attr_name) | ||
| # except AttributeError as exc: | ||
| # raise missing_a2a_sdk_error(feature, exc) from exc |
| @@ -0,0 +1,108 @@ | |||
| import pytest | |||
| from unittest.mock import MagicMock, AsyncMock, patch | |||
|
|
||
| import pytest | ||
| from unittest.mock import AsyncMock, MagicMock, patch | ||
| from typing import Any |
| import pytest | ||
| from unittest.mock import AsyncMock, MagicMock, patch | ||
| from typing import Any | ||
| from pathlib import Path |
| create_eval_app, | ||
| create_simple_eval_set, | ||
| ) | ||
| from agentflow.qa.evaluation.eval_result import EvalReport |
| create_simple_eval_set, | ||
| ) | ||
| from agentflow.qa.evaluation.eval_result import EvalReport | ||
| from agentflow.core.graph.compiled_graph import CompiledGraph |
| from unittest.mock import AsyncMock, MagicMock, patch | ||
| from typing import Any | ||
| import json | ||
| import uuid |
Comment on lines
+9
to
+14
| from agentflow.qa.evaluation.simulators.user_simulator import ( | ||
| UserSimulator, | ||
| BatchSimulator, | ||
| ConversationScenario, | ||
| SimulationResult | ||
| ) |
|
|
||
| # 2. With cached content (system prompt should be ignored) | ||
| mock_client.aio.models.generate_content.reset_mock() | ||
| res = await _call_google( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.