1+ #!/usr/bin/env python3
2+ # SPDX-License-Identifier: Apache-2.0
3+ # Copyright Contributors to the rawtoaces Project.
4+
5+ """
6+ Unit tests for rawtoaces Python bindings - ImageConverter class
7+ """
8+
9+ import pytest
10+
11+ # The PYTHONPATH should be set by CMake to find the compiled module
12+ # No need to manually add paths here as CMake handles this via environment variables
13+
14+ try :
15+ import rawtoaces
16+ except ImportError as e :
17+ pytest .skip (f"rawtoaces module not found. Build the Python bindings first: { e } " , allow_module_level = True )
18+
19+
20+ class TestImageConverter :
21+ """Test cases for the ImageConverter class"""
22+
23+ def test_converter_creation (self ):
24+ """Test that ImageConverter can be instantiated"""
25+ converter = rawtoaces .ImageConverter ()
26+ assert converter is not None
27+ assert isinstance (converter , rawtoaces .ImageConverter )
28+
29+ def test_converter_has_settings (self ):
30+ """Test that ImageConverter has a settings attribute"""
31+ converter = rawtoaces .ImageConverter ()
32+ assert hasattr (converter , "settings" )
33+ assert converter .settings is not None
34+
35+ def test_converter_has_process_image_method (self ):
36+ """Test that ImageConverter has process_image method"""
37+ converter = rawtoaces .ImageConverter ()
38+ assert hasattr (converter , "process_image" )
39+ assert callable (converter .process_image )
40+
41+ def test_process_image_with_invalid_path (self ):
42+ """Test process_image with non-existent file returns False"""
43+ converter = rawtoaces .ImageConverter ()
44+ result = converter .process_image ("/nonexistent/file.txt" )
45+ assert result is False
46+
47+ result = converter .process_image ("" )
48+ assert result is False
49+
50+
51+ class TestSettings :
52+ """Test cases for the ImageConverter.Settings class"""
53+
54+ def test_settings_creation (self ):
55+ """Test that Settings can be instantiated"""
56+ converter = rawtoaces .ImageConverter ()
57+ settings = converter .settings
58+ assert settings is not None
59+ assert isinstance (settings , rawtoaces .ImageConverter .Settings )
60+
61+ def test_settings_direct_creation (self ):
62+ """Test that Settings can be created directly"""
63+ settings = rawtoaces .ImageConverter .Settings ()
64+ assert settings is not None
65+ assert isinstance (settings , rawtoaces .ImageConverter .Settings )
66+
67+
68+ if __name__ == "__main__" :
69+ pytest .main ([__file__ ])
0 commit comments