test: add comprehensive unit tests for core, tools, and dispatcher modules#159
Merged
test: add comprehensive unit tests for core, tools, and dispatcher modules#159
Conversation
…rypoints **Added:** - Coverage and behavior tests for additional dataclasses, Redis helpers, and CLI commands in `tests/cli/test_main.py` - Tests for blue worker, multi-agent, and worker CLI command paths in `tests/cli/test_main.py` - Tests for error handling and edge cases in `tests/core/test_k8s_executor.py`, including pod discovery, execution retries, pod log retrieval, and file transfer error cases - Tests for query chunked execution error handling, non-retryable error propagation, and custom exception usage in `tests/core/test_query_resilience.py` - New `tests/test_smoke_coverage.py` with smoke tests for public exceptions and package version attribute **Changed:** - Refactored and expanded test assertions in CLI and core test modules to improve robustness and coverage, including parameterized tests for multi-agent routing and deduplication logic - Improved docstrings and comments for clarity in several test modules **Removed:** - Eliminated redundant code and comments in test cases to streamline and clarify test intent
…guration **Added:** - Tests for LiteLLM environment variable defaults and preservation of existing values in `test_litellm_env.py` - Unit tests for logging utility `truncate_output` covering edge cases and truncation logic in `test_logging_utils.py` - Comprehensive tests for inter-agent messaging primitives, including ID generation, message serialization, and message factory behavior in `test_messages.py` **Changed:** - Updated smoke coverage test to only verify top-level package importability and presence of `__name__` attribute in `test_smoke_coverage.py` **Removed:** - Removed coverage checks for custom exception messages and version attribute from the smoke test to focus on import coverage
…appers **Added:** - Added tests for BluePublishingMixin covering evidence, timeline, technique, and lateral connection publishing in `tests/core/blue_dispatcher/test_publishing.py` - Added tests for BlueStatusMixin summarization, task status, and evidence aggregation in `tests/core/blue_dispatcher/test_status.py` - Added comprehensive tests for SharedInvestigationTools covering evidence recording, timeline events, entity tracking, lateral connections, read helpers, and stage transitions in `tests/tools/blue/test_shared_wrappers.py` **Changed:** - Normalized hostnames in lateral connection publishing for BluePublishingMixin and SharedInvestigationTools to consistently use lowercased, stripped values - Improved docstrings for methods in SharedInvestigationTools to clarify backend, shared state, and MITRE client usage - Standardized logging and returned messages in lateral connection publishing to use normalized hostnames in both BluePublishingMixin and SharedInvestigationTools - Updated parameter and return docstrings in `get_operation_status` for clarity in `src/ares/core/orchestrator_client.py` - Simplified type alias usage in `src/ares/core/correlation.py` by removing an unused `TypeAlias` - Improved docstrings for `resolve_recon_route` in red common utilities to clarify argument and return semantics - Refactored socket handling in `infer_listener_ip` to ensure sockets are always closed in `src/ares/tools/red/common.py` - Updated test assertion in `tests/test_messages.py` to use equality comparison for message type **Removed:** - Removed redundant or unused type alias definition in `src/ares/core/correlation.py`
…stency **Changed:** - Switched pytest.mark.parametrize argument lists from quoted strings to tuples for improved readability and alignment with pytest best practices in test_logging_utils.py, test_messages.py, and tools/blue/test_shared_wrappers.py - Renamed lambda parameter from technique_id to _technique_id to indicate unused variable in tools/blue/test_shared_wrappers.py
**Changed:** - Reformatted argument lists and context manager usage in test files to use multi-line and parenthesized style for improved readability (`test_shared_wrappers.py`) - Consolidated and aligned patch statements for clarity and easier maintenance (`test_shared_wrappers.py`) - Reformatted long lines and function calls in test assertions to fit within line length limits and enhance code clarity (`test_publishing.py`, `test_shared_wrappers.py`, `test_status.py`)
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.
Key Changes:
Added:
tests/core/blue_dispatcher/test_publishing.py) covering evidence, timeline, technique, and lateral connection publishing behaviorstests/core/blue_dispatcher/test_status.py) verifying investigation summary, task status, and evidence summary aggregationtests/core/test_k8s_executor.py) including pod management, retries, file transfer, and log retrieval scenariostests/core/test_query_resilience.py) to validate chunked execution, retry/error handling, and stats aggregationtests/cli/test_main.pycovering argument parsing, Redis-backed operation discovery, entrypoints, and main control flow including multi-agent dispatch and report generationtests/tools/blue/test_shared_wrappers.py) validating evidence, timeline, correlation, and state transition helperstests/test_smoke_coverage.py)tests/test_messages.py) for ID generation, model serialization, and message factory logictests/test_logging_utils.py) for output truncation logictests/test_litellm_env.py) to verify environment variable defaults and preservation of user valuesChanged:
Removed: