-
-
Notifications
You must be signed in to change notification settings - Fork 80
feat(tests): init #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(tests): init #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive test suite for RecuperaBit with both unit tests and end-to-end (E2E) tests. The implementation includes basic unit tests for NTFS parsing functions, integration tests for core logic components, and E2E tests that use reference NTFS filesystem images without requiring external dependencies.
Key changes:
- Adds unit tests for NTFS parsing functions and core types
- Implements E2E tests using reference NTFS filesystem images
- Creates tools for building reference test images
Reviewed Changes
Copilot reviewed 20 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/build_reference_ntfs.py | Script for creating reference NTFS filesystem images for E2E testing |
| tests/test_ntfs_unit.py | Unit tests for NTFS parsing functions and core types |
| tests/test_ntfs_e2e.py | End-to-end tests using reference NTFS images |
| tests/test_integration.py | Integration tests for RecuperaBit logic and utilities |
| tests/run_tests.py | Test runner and configuration script |
| tests/reference_image.py | Utilities for managing reference NTFS images |
| tests/data/reference_ntfs.json | Metadata for reference NTFS image |
| tests/data/reference_files/* | Sample test files for building reference images |
| tests/init.py | Test suite initialization |
| recuperabit/utils.py | Type annotations and utility function updates |
| recuperabit/logic.py | Type annotations for core logic classes |
| recuperabit/fs/ntfs.py | Type annotations for NTFS module |
| recuperabit/fs/core_types.py | Type annotations for core filesystem types |
| recuperabit/fs/constants.py | Type annotations for constants |
| main.py | Type annotations for main module |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| def test_unpack_insufficient_data(self): | ||
| """Test unpack function with insufficient data.""" | ||
| # Create short test data | ||
| test_data = b'\x01\x02' | ||
|
|
||
| # Format that requires more data than available | ||
| test_format = [ | ||
| ('valid_data', ('i', 0, 1)), # Valid range | ||
| ('out_of_bounds', ('i', 5, 8)) # Tries to read beyond data | ||
| ] | ||
|
|
||
| # Should handle gracefully, setting None for missing data | ||
| result = unpack(test_data, test_format) | ||
|
|
||
| # Should have valid data for first field | ||
| self.assertIn('valid_data', result) | ||
| # Should handle out of bounds gracefully | ||
| self.assertIn('out_of_bounds', result) |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method test_unpack_insufficient_data is defined twice in the same class, which will cause the second definition to override the first one. This is likely a copy-paste error.
| def test_unpack_insufficient_data(self): | |
| """Test unpack function with insufficient data.""" | |
| # Create short test data | |
| test_data = b'\x01\x02' | |
| # Format that requires more data than available | |
| test_format = [ | |
| ('valid_data', ('i', 0, 1)), # Valid range | |
| ('out_of_bounds', ('i', 5, 8)) # Tries to read beyond data | |
| ] | |
| # Should handle gracefully, setting None for missing data | |
| result = unpack(test_data, test_format) | |
| # Should have valid data for first field | |
| self.assertIn('valid_data', result) | |
| # Should handle out of bounds gracefully | |
| self.assertIn('out_of_bounds', result) | |
| # (Removed duplicate test_unpack_insufficient_data method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch lol
| import readline | ||
| readline # ignore unused import warning |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using a bare variable reference to suppress unused import warnings is unconventional. Consider using # noqa comment or restructure the import handling more cleanly.
| import readline | |
| readline # ignore unused import warning | |
| import readline # noqa: F401 |
|
|
||
| def exists(self) -> bool: | ||
| """Check if the reference image exists.""" | ||
| print(self.image_path, self.metadata_path) |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement should be removed from production code. Consider using logging instead if this information is needed for debugging.
| print(self.image_path, self.metadata_path) | |
| self.logger.debug(f"Checking existence: image_path={self.image_path}, metadata_path={self.metadata_path}") |
Add basic unit tests and E2E tests, without any external dependencies (except for building the test image, but this is a one-time operation).
Can be ran using
python tests/run_tests.pyorpython -m unittest.