Skip to content

Conversation

@tnm
Copy link
Contributor

@tnm tnm commented Nov 12, 2025

Summary

This PR fixes a bug in the health_check() method and adds comprehensive test coverage for the Hopx provider introduced in PR #9.

Changes

🐛 Bug Fixes

health_check robustness (sandboxes/providers/hopx.py:548)

  • Handle None return from HopxSandbox.list() API
  • Previously would crash with 'NoneType' object is not iterable
  • Now explicitly checks if result is not None before returning True

✅ Testing Improvements

pytest marker registration (tests/conftest.py:138)

  • Add pytest.mark.hopx marker registration
  • Removes PytestUnknownMarkWarning
  • Consistent with other provider markers (e2b, daytona, modal)

4 new comprehensive test cases (tests/test_hopx_provider.py:712-870):

  1. test_hopx_timeout_parameter_compatibility - Verify timeout parameters passed correctly to SDK
  2. test_hopx_concurrent_command_execution - Test concurrent command execution
  3. test_hopx_environment_variables_in_commands - Verify env vars properly passed
  4. test_hopx_health_check_handles_none_response - Test health_check edge cases

Test Results

All 26 unit tests pass (previously 22)

$ pytest tests/test_hopx_provider.py -v -k "not live"
================= 26 passed, 1 deselected, 3 warnings in 0.85s =================

Real API testing confirms fixes work

  • Health check returns True correctly
  • run_code() functionality verified with real sandbox
  • Sandbox creation and destruction work as expected

Impact

  • ✅ Improves provider reliability and error handling
  • ✅ Increases test coverage from 22 to 26 tests (+18%)
  • ✅ No breaking changes to existing functionality
  • ✅ All existing tests continue to pass

Related

This PR builds on the excellent work in PR #9 by adding additional safety checks and test coverage.

tnm added 3 commits November 12, 2025 14:05
## Changes

### Bug Fixes
- **health_check**: Handle None return from HopxSandbox.list() API
  - Previously would crash with "NoneType object is not iterable"
  - Now explicitly checks if result is not None before returning True
  - Provides better error handling for API responses

### Testing
- Add pytest.mark.hopx marker registration to conftest.py
  - Removes PytestUnknownMarkWarning
  - Consistent with other provider markers (e2b, daytona, modal)

### New Test Cases
Added 4 comprehensive test cases:
1. **test_hopx_timeout_parameter_compatibility**: Verify timeout parameters passed correctly to SDK methods
2. **test_hopx_concurrent_command_execution**: Test concurrent command execution in same sandbox
3. **test_hopx_environment_variables_in_commands**: Verify env vars properly passed to commands
4. **test_hopx_health_check_handles_none_response**: Test health_check with None/empty/non-empty responses

## Test Results
- All 26 unit tests pass
- Real API testing confirms health_check works correctly
- run_code() functionality verified with real sandbox

## Impact
- Improves provider reliability and error handling
- Increases test coverage from 22 to 26 tests
- No breaking changes to existing functionality
@tnm tnm merged commit 20c5d84 into main Nov 12, 2025
4 checks passed
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