Skip to content

Conversation

llbbl
Copy link

@llbbl llbbl commented Jun 14, 2025

Add Testing Infrastructure to qr-filetransfer

Summary

This PR introduces a comprehensive testing infrastructure to the qr-filetransfer project using Poetry as the package manager and pytest as the testing framework. The setup enables developers to immediately start writing tests with proper tooling and configuration.

Changes Made

Package Management

  • Poetry Configuration: Created pyproject.toml with complete project metadata
  • Dependency Migration: Migrated dependencies from requirements.txt and setup.py to Poetry
  • Development Dependencies: Added pytest, pytest-cov, and pytest-mock as dev dependencies

Testing Framework

  • Directory Structure:
    tests/
    ├── __init__.py
    ├── conftest.py           # Shared fixtures
    ├── test_setup_validation.py
    ├── unit/
    │   └── __init__.py
    └── integration/
        └── __init__.py
    

Configuration

  • pytest Configuration:

    • Test discovery patterns for files, classes, and functions
    • Custom markers: unit, integration, slow
    • Coverage reporting with HTML and XML output
    • Verbose output with strict markers
  • Coverage Configuration:

    • Source coverage for qr_filetransfer package
    • Exclusion patterns for test files and virtual environments
    • HTML coverage reports in htmlcov/ directory
    • XML coverage report as coverage.xml

Fixtures (in conftest.py)

  • temp_dir: Creates temporary directories for testing
  • temp_file: Creates temporary files with test content
  • mock_config: Mock configuration object
  • mock_qr_generator: Mock QR code generator
  • test_environment: Sets up test environment variables
  • mock_network_interface: Mock network interface
  • sample_files: Creates sample test files
  • mock_server: Mock HTTP server

Other Updates

  • Updated .gitignore: Added entries for testing artifacts, Python files, virtual environments, and IDE files
  • Validation Tests: Created tests to verify the infrastructure works correctly

Running Tests

Install dependencies:

poetry install

Run all tests:

poetry run pytest

Run tests with specific markers:

poetry run pytest -m unit        # Run only unit tests
poetry run pytest -m integration # Run only integration tests
poetry run pytest -m "not slow"  # Skip slow tests

View coverage report:

# Terminal report is shown automatically
# HTML report available at:
open htmlcov/index.html

Notes

  • The coverage threshold is currently set to 0% since this PR only sets up infrastructure
  • Developers should update the coverage threshold in pyproject.toml as they add tests
  • The poetry.lock file should be committed to ensure reproducible builds
  • All validation tests pass, confirming the infrastructure is working correctly

- Set up Poetry as package manager with pyproject.toml configuration
- Add pytest, pytest-cov, and pytest-mock as development dependencies
- Configure pytest with custom markers (unit, integration, slow)
- Set up coverage reporting with HTML and XML output
- Create testing directory structure with conftest.py fixtures
- Update .gitignore with testing and Python-related entries
- Add validation tests to verify testing infrastructure
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