Skip to content

test: add comprehensive unit tests for core, tools, and dispatcher modules#159

Merged
l50 merged 6 commits intomainfrom
chore/misc-fixes
Mar 18, 2026
Merged

test: add comprehensive unit tests for core, tools, and dispatcher modules#159
l50 merged 6 commits intomainfrom
chore/misc-fixes

Conversation

@l50
Copy link
Copy Markdown
Contributor

@l50 l50 commented Mar 18, 2026

Key Changes:

  • Added thorough unit and integration tests for core modules and CLI logic
  • Introduced tests for blue dispatcher publishing and status mixins
  • Added tests for Kubernetes executor and shared investigation wrappers
  • Improved coverage for message primitives, logging utils, and LiteLLM environment config

Added:

  • Unit tests for core blue dispatcher publishing (tests/core/blue_dispatcher/test_publishing.py) covering evidence, timeline, technique, and lateral connection publishing behaviors
  • Unit tests for blue dispatcher status mixin (tests/core/blue_dispatcher/test_status.py) verifying investigation summary, task status, and evidence summary aggregation
  • Extensive tests for the Kubernetes executor (tests/core/test_k8s_executor.py) including pod management, retries, file transfer, and log retrieval scenarios
  • Additional tests for query resilience logic (tests/core/test_query_resilience.py) to validate chunked execution, retry/error handling, and stats aggregation
  • CLI and dataclass tests in tests/cli/test_main.py covering argument parsing, Redis-backed operation discovery, entrypoints, and main control flow including multi-agent dispatch and report generation
  • Tests for shared investigation wrappers (tests/tools/blue/test_shared_wrappers.py) validating evidence, timeline, correlation, and state transition helpers
  • Smoke test for top-level package importability (tests/test_smoke_coverage.py)
  • Message primitives tests (tests/test_messages.py) for ID generation, model serialization, and message factory logic
  • Logging utility tests (tests/test_logging_utils.py) for output truncation logic
  • LiteLLM environment configuration tests (tests/test_litellm_env.py) to verify environment variable defaults and preservation of user values

Changed:

  • Parametrized and expanded test coverage in existing test files, especially for severity routing, alert merging, and command-line argument handling in the CLI tests
  • Improved test clarity and assertions to ensure accurate behavior for edge cases and error paths across core and tools modules

Removed:

  • Legacy and redundant test code replaced by more thorough and explicit scenarios in the new and updated test modules

l50 added 3 commits March 17, 2026 15:49
…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`
l50 added 3 commits March 18, 2026 00:54
…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`)
@l50 l50 merged commit c4881eb into main Mar 18, 2026
7 checks passed
@l50 l50 deleted the chore/misc-fixes branch March 18, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant