ReconAIzer icon indicating copy to clipboard operation
ReconAIzer copied to clipboard

feat: Set up Python testing infrastructure with Poetry

Open llbbl opened this issue 5 months ago • 0 comments

Set up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the ReconAIzer project using Poetry as the package manager and pytest as the testing framework. The setup provides everything needed for developers to immediately start writing and running tests.

Changes Made

Package Management

  • Poetry Setup: Initialized Poetry as the package manager with pyproject.toml configuration
  • Python Version: Set to support Python 3.8+
  • Package Structure: Created reconaizer package directory and moved existing code

Testing Dependencies

Added the following development dependencies:

  • pytest (^7.4.0) - Main testing framework
  • pytest-cov (^4.1.0) - Coverage reporting
  • pytest-mock (^3.11.1) - Mocking utilities

Testing Configuration

Configured in pyproject.toml:

  • Test Discovery: Configured to find tests in tests/ directory
  • Coverage Settings:
    • Source tracking for reconaizer package
    • HTML and XML report generation
    • Coverage threshold set to 0% (to be increased as tests are added)
  • Test Markers: Added unit, integration, and slow markers
  • Strict Options: Enabled strict markers and configuration

Directory Structure

tests/
├── __init__.py
├── conftest.py           # Shared fixtures
├── test_setup_validation.py  # Infrastructure validation
├── unit/
│   └── __init__.py
└── integration/
    └── __init__.py

Shared Fixtures (conftest.py)

Created comprehensive fixtures for common testing needs:

  • temp_dir - Temporary directory management
  • mock_config - Mock configuration objects
  • mock_api_client - Mock API client
  • sample_request_data - Sample HTTP request data
  • sample_response_data - Sample HTTP response data
  • mock_burp_callbacks - Mock Burp Suite callbacks
  • mock_file_system - File system operation mocking
  • capture_logs - Log capture utility

Development Commands

Set up Poetry scripts for running tests:

poetry run test   # Run all tests
poetry run tests  # Alternative command

Both commands support all standard pytest options.

Additional Files

  • .gitignore: Updated with comprehensive Python, testing, and IDE-related entries
  • Validation Tests: Created test_setup_validation.py to verify the infrastructure setup

How to Use

  1. Install Poetry (if not already installed):

    curl -sSL https://install.python-poetry.org | python3 -
    
  2. Install Dependencies:

    poetry install
    
  3. Run Tests:

    poetry run test
    # or
    poetry run tests
    
  4. Run Tests with Specific Markers:

    poetry run test -m unit
    poetry run test -m integration
    poetry run test -m "not slow"
    
  5. View Coverage Reports:

    • Terminal: Automatically shown after test runs
    • HTML: Open htmlcov/index.html in a browser
    • XML: Available at coverage.xml for CI integration

Next Steps

With this infrastructure in place, developers can now:

  1. Write unit tests in tests/unit/
  2. Write integration tests in tests/integration/
  3. Use the provided fixtures for common testing scenarios
  4. Gradually increase the coverage threshold as tests are added

Notes

  • The coverage threshold is currently set to 0% to allow the infrastructure to be merged without requiring immediate test coverage
  • The original Burp extension code has been moved to the reconaizer package for better organization
  • Lock files (poetry.lock) should be committed to ensure reproducible builds

llbbl avatar Jun 28 '25 21:06 llbbl