Skip to content

Conversation

@aviallon
Copy link
Collaborator

@aviallon aviallon commented Sep 28, 2025

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.py or python -m unittest.

@aviallon aviallon requested a review from Copilot October 13, 2025 20:47
Copy link

Copilot AI left a 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.

Comment on lines +259 to +276
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)
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch lol

Comment on lines 32 to +33
import readline
readline # ignore unused import warning
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
import readline
readline # ignore unused import warning
import readline # noqa: F401

Copilot uses AI. Check for mistakes.

def exists(self) -> bool:
"""Check if the reference image exists."""
print(self.image_path, self.metadata_path)
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
print(self.image_path, self.metadata_path)
self.logger.debug(f"Checking existence: image_path={self.image_path}, metadata_path={self.metadata_path}")

Copilot uses AI. Check for mistakes.
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