feat: Add comprehensive Python testing infrastructure #31
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.
Add Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the RedWarden project, transitioning from basic
requirements.txt
to modern Poetry dependency management and adding pytest with full coverage reporting capabilities.Changes Made
1. Package Management Migration
pyproject.toml
with Poetry configurationrequirements.txt
maintained2. Testing Configuration
pyproject.toml
3. Test Directory Structure
4. Shared Test Fixtures
Created comprehensive fixtures in
conftest.py
:temp_dir
: Temporary directory for test filesmock_config
: Mock configuration dictionarymock_yaml_config
: Temporary YAML config filemock_logger
: Mock logger objectmock_request
/mock_response
: HTTP request/response mocksmock_plugin
: Mock plugin objectreset_environment
: Environment isolation between testssample_malleable_profile
: Sample C2 profile for testingisolated_imports
: Import isolation between tests5. Development Tooling
.gitignore
with comprehensive Python/testing/IDE entriespoetry run test
andpoetry run tests
Instructions for Running Tests
Initial Setup
Running Tests
Coverage Reports
htmlcov/index.html
in a browsercoverage.xml
for CI integrationNext Steps
--cov-fail-under
from 0 to 80 inpyproject.toml
when writing actual teststests/unit/
tests/integration/
coverage.xml
for CI coverage reportingNotes
poetry.lock
file is gitignored as specified in requirements