Skip to content

Add exhaustive pytest test suite (169 tests)#78

Open
deacon-mp wants to merge 1 commit intomasterfrom
test/exhaustive-pytest-coverage
Open

Add exhaustive pytest test suite (169 tests)#78
deacon-mp wants to merge 1 commit intomasterfrom
test/exhaustive-pytest-coverage

Conversation

@deacon-mp
Copy link
Copy Markdown
Contributor

Summary

  • Adds a comprehensive pytest test suite with 169 tests covering every Python module in the response plugin
  • Tests cover: ResponseService (response planning, fact filtering, PID tracking, operation lifecycle), ProcessNode/ProcessTree (tree operations, parent/child traversal, PID-to-GUID mapping, store dedup), all 8 parsers (basic_strip, childprocess, ecs_sysmon, key_value, ports, process, processguids, sysmon), all 4 requirements (base_requirement, basic, has_property, source_fact), and hook.py (metadata, enable, expansion)
  • Includes pytest.ini, tox.ini, and a conftest.py with lightweight framework stubs enabling isolated testing without the full Caldera installation

Test plan

  • All 169 tests pass locally with pytest -v
  • CI validates test collection and execution
  • Verify no regressions on existing functionality

Generated with Claude Code

Tests cover: ResponseService (response planning, fact filtering, PID
tracking, operation lifecycle), ProcessNode/ProcessTree (tree operations,
parent/child traversal, PID-to-GUID mapping, store dedup), all 8 parsers
(basic_strip, childprocess, ecs_sysmon, key_value, ports, process,
processguids, sysmon), all 4 requirements (base_requirement, basic,
has_property, source_fact), and hook.py (metadata, enable, expansion).

Includes pytest.ini, tox.ini, and a conftest.py with lightweight framework
stubs enabling isolated testing without the full Caldera installation.
@deacon-mp deacon-mp requested a review from Copilot March 16, 2026 14:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new pytest-based test suite intended to comprehensively cover the response plugin’s core services, process tree logic, parsers, requirements, and hook integration, along with local tooling to run tests via pytest/tox.

Changes:

  • Introduces new pytest tests for ResponseService, ProcessNode/ProcessTree, parsers, requirements, and hook.py
  • Adds a lightweight conftest.py that stubs Caldera/framework modules and loads plugin modules for isolated execution
  • Adds pytest.ini and tox.ini to standardize local test execution across multiple Python versions

Reviewed changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tox.ini Adds tox environments to run pytest across multiple Python versions
pytest.ini Configures pytest discovery and asyncio handling
tests/conftest.py Provides framework stubs + dynamic module loading to run plugin tests without Caldera
tests/test_response_svc.py Unit tests for ResponseService helpers and key flows
tests/test_process_tree.py Tests for ProcessNode and ProcessTree behavior
tests/test_hook.py Tests plugin metadata and enable/expansion behavior
tests/test_parsers/test_basic_strip.py Tests basic_strip parser
tests/test_parsers/test_childprocess.py Tests childprocess parser
tests/test_parsers/test_ecs_sysmon.py Tests ecs_sysmon parser
tests/test_parsers/test_key_value.py Tests key_value parser
tests/test_parsers/test_ports.py Tests ports parser
tests/test_parsers/test_process.py Tests process parser
tests/test_parsers/test_processguids.py Tests processguids parser
tests/test_parsers/test_sysmon.py Tests sysmon parser
tests/test_requirements/test_base_requirement.py Tests BaseRequirement helpers/validation
tests/test_requirements/test_basic.py Tests basic requirement
tests/test_requirements/test_has_property.py Tests has_property requirement
tests/test_requirements/test_source_fact.py Tests source_fact requirement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +10

# Root of the cloned repo
REPO_ROOT = '/tmp/response-pytest'
Comment on lines +2 to +10
import sys
import json
import asyncio
import pytest
from unittest.mock import AsyncMock, MagicMock, patch

sys.path.insert(0, '/tmp/response-pytest')

from tests.conftest import (
Comment on lines +39 to +42
call_kwargs = BaseWorld.set_config.call_args
assert 'test-ability-id' in call_kwargs[1]['value'] or 'test-ability-id' in call_kwargs[0][0] if call_kwargs[0] else True


Comment on lines +3 to +6
import json
import asyncio
import pytest
from unittest.mock import AsyncMock, MagicMock, patch
return mod


def _install_stubs():
Comment on lines +293 to +294
_install_stubs()

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.

2 participants