awspx
awspx copied to clipboard
feat: Add comprehensive Python testing infrastructure with Poetry
Add Python Testing Infrastructure
Summary
This PR sets up a comprehensive testing infrastructure for the awspx Python project using Poetry as the package manager and pytest as the testing framework.
Changes Made
Package Management
- Set up Poetry as the project's package manager
- Created
pyproject.tomlwith all project dependencies and development dependencies - Configured Poetry to manage both
libandscriptspackages
Testing Framework
- Added pytest with coverage and mocking utilities as development dependencies
- Configured pytest with:
- Coverage reporting (HTML, XML, and terminal output)
- Custom markers for test categorization (
unit,integration,slow) - Strict test discovery patterns
- Comprehensive test output formatting
Project Structure
- Created organized test directory structure:
tests/ ├── __init__.py ├── conftest.py # Shared pytest fixtures ├── test_setup_validation.py # Infrastructure validation tests ├── unit/ │ └── __init__.py └── integration/ └── __init__.py
Testing Fixtures
Added comprehensive shared fixtures in conftest.py:
temp_dir- Temporary directory for test filesmock_boto3_client- Mock AWS client for testingmock_boto3_session- Mock AWS sessionmock_neo4j_driver- Mock Neo4j driver for graph database testingsample_aws_config- Sample AWS configurationsample_aws_resource- Sample AWS resource datareset_environment- Auto-reset environment variablesmock_console- Mock console for output testingmock_git_repo- Mock git repository
Development Commands
Configured Poetry scripts for running tests:
poetry run test- Run all tests with coveragepoetry run tests- Alternative command (both work identically)
Both commands support all standard pytest options.
Additional Configuration
- Updated
.gitignorewith:- Testing artifacts (
.pytest_cache/,.coverage,htmlcov/, etc.) - Virtual environment directories
- IDE files
- Build artifacts
- Claude settings directory (
.claude/*)
- Testing artifacts (
How to Use
-
Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 - -
Install dependencies:
poetry install -
Run tests:
# Run all tests poetry run test # Run with specific options poetry run test tests/unit/ -v # Run specific test markers poetry run test -m unit poetry run test -m "not slow" -
View coverage report:
- HTML report: Open
htmlcov/index.htmlin a browser - XML report: Available at
coverage.xml - Terminal report: Shown automatically after test run
- HTML report: Open
Notes
- The infrastructure is set up with an 80% coverage threshold configured in
pyproject.toml - All test dependencies are properly isolated as development dependencies
- The validation tests verify that the infrastructure is working correctly
- No actual unit tests for the codebase were written - this PR only sets up the infrastructure
Next Steps
With this testing infrastructure in place, developers can now:
- Write unit tests for individual modules
- Create integration tests for AWS service interactions
- Add performance tests using the
@pytest.mark.slowmarker - Leverage the provided fixtures for consistent test setup