Skip to content

Conversation

@jasondaming
Copy link

Summary

Adds comprehensive unit tests for the robotpy deploy command, covering core functionality with 22 tests.

Changes

  • tests/test_deploy.py: 22 unit tests covering deploy command functionality
  • tests/TEST_COVERAGE.md: Documentation of test coverage and future expansion areas

Test Coverage

What's Tested (22 tests, all passing ✅)

  • SSH error handling and context management (2 tests)
  • File operations and filtering (6 tests)
    • Ignores: hidden files, .pyc, __pycache__, venv, .whl files
  • Large file detection and user confirmation (3 tests)
  • Build metadata generation with git integration (2 tests)
  • Package caching and management (3 tests)
  • Deploy workflow controls (3 tests)
    • Home directory blocking
    • Test execution control
    • Skip tests flag
  • Command-line argument parsing (1 test)
  • Integration test for complete deploy workflow (1 test)

Testing Strategy

  • Uses extensive mocking to avoid requiring actual robot hardware
  • Tests are isolated, fast, and include proper cleanup
  • Tests both success and failure scenarios
  • Follows Arrange-Act-Assert pattern

Running the Tests

# Run all deploy tests
python3 -m pytest tests/test_deploy.py -v

# Run with coverage
python3 -m pytest tests/test_deploy.py --cov=robotpy_installer.cli_deploy

Future Expansion

The TEST_COVERAGE.md document outlines areas for future test expansion including:

  • SSH/Robot communication testing
  • Requirements management flows
  • Deploy execution edge cases
  • Network failure scenarios

This PR establishes a foundation for testing the deploy command and provides patterns that can be used for testing other commands in robotpy-installer.

Added 22 unit tests for the robotpy deploy command covering:
- SSH error handling and context management
- File operations and filtering (hidden files, pyc, pycache, venv, whl)
- Large file detection and user confirmation
- Build metadata generation with git integration
- Package caching and management
- Deploy workflow (home directory blocking, test execution)
- Command-line argument parsing
- Integration test for complete deploy workflow

All tests use mocking to avoid requiring actual robot hardware.
Tests are isolated, fast, and include proper cleanup.

Also added TEST_COVERAGE.md documenting test coverage and future
expansion areas.
@virtuald
Copy link
Member

virtuald commented Oct 8, 2025

I've generally found that extensive mocks in tests just make things annoying to modify in the future, so I'm inclined to not go forward with this. I was hoping the mocks would be less invasive, or maybe it would stand up a fake SSH server using paramiko, or just mock the SSH client.

Also, it definitely needs to be pytest-style test cases, not unittest.

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