feat: add unit tests and integration tests
Context
This MR implements comprehensive unit and integration testing for the aidge_export_tensorrt module. The test suite provides complete coverage of export functionality, file generation, and plugin registry operations to ensure code reliability and maintainability.
Modified files
- 
test_export.py(18 tests) - Unit tests for main export functionality - 
test_file_generation.py(9 tests) - Unit tests for file and plugin generation - 
test_plugin_registry.py(6 tests) - Unit tests for plugin registry operations - 
test_integration.py(8 tests) - Integration tests for end-to-end functionality 
Total: 41 tests covering all module functionality
Detailed major modifications
Test Architecture & Coverage
Export Functionality (18 tests)
- 
Input Validation: GraphView/string type detection, ONNX extension validation with 
endswithchecks - 
File Operations: Directory creation with 
os.makedirs, file copying viashutil.copy, renaming tomodel.onnx - 
TensorRT Integration: Version-specific static file copying (default: 10.10) with 
shutil.copytree - 
PyBind11 Integration: Git cloning with 
subprocess.runmanagement and error handling - 
Error Handling: Invalid inputs, missing files, 
CalledProcessErrorandFileNotFoundErrorscenarios 
File Generation (9 tests)
- Template Rendering: Jinja2 template processing with variable substitution and nested directory support
 - 
Directory Structure: Multi-level directory creation for plugins using 
os.makedirs - 
Plugin Generation: 
.hppand.cufile creation inplugins/pluginname/structure - Error Handling: Template validation and file system error simulation
 
Plugin Registry (6 tests)
- 
Registration System: Single/multiple plugin decorators with 
@plugin_registry.register - Key Management: Multiple aliases for same plugin using list-based key registration
 - Functionality Preservation: Decorated function callability maintained after registration
 
Integration Tests (8 tests)
- End-to-End Workflow: Complete export with ONNX files and GraphView objects
 - Real-World Scenarios: Concurrent operations with thread safety, large file handling (1MB+)
 - Error Integration: File not found, invalid inputs in full context with proper cleanup
 - Version Handling: Different TensorRT version support (8.6, 10.10) with static file management
 
Test Environment & Mocking Strategy
Isolation & Cleanup
- 
Temporary Directories: 
tempfile.mkdtemp()for isolated testing environment - 
Automatic Cleanup: 
shutil.rmtree()intearDown()methods - State Restoration: Original module state restored after each test
 
Mocking Architecture
| Component | Mock Target | Purpose | 
|---|---|---|
| External Dependencies | 
aidge_core, aidge_onnx
 | 
Isolate unit under test from external modules | 
| File Operations | 
shutil.copy, shutil.copytree, os.rename
 | 
Control file system behavior without actual I/O | 
| System Calls | subprocess.run | 
Avoid actual git operations during testing | 
| Error Conditions | File not found scenarios | Test error handling paths and edge cases |