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+ import sys
11+ import os
12+
13+ # Add build directory to path to import the compiled module
14+ # NOTE: Adjust this path based on your build configuration
15+ sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), '../../build/src/bindings' ))
16+
17+ try :
18+ import rawtoaces
19+ except ImportError as e :
20+ pytest .skip (f"rawtoaces module not found. Build the Python bindings first: { e } " , allow_module_level = True )
21+
22+
23+ class TestImageConverter :
24+ """Test cases for the ImageConverter class"""
25+
26+ def test_converter_creation (self ):
27+ """Test that ImageConverter can be instantiated"""
28+ converter = rawtoaces .ImageConverter ()
29+ assert converter is not None
30+ assert isinstance (converter , rawtoaces .ImageConverter )
31+
32+ def test_converter_has_settings (self ):
33+ """Test that ImageConverter has a settings attribute"""
34+ converter = rawtoaces .ImageConverter ()
35+ assert hasattr (converter , "settings" )
36+ assert converter .settings is not None
37+
38+ def test_converter_has_process_image_method (self ):
39+ """Test that ImageConverter has process_image method"""
40+ converter = rawtoaces .ImageConverter ()
41+ assert hasattr (converter , "process_image" )
42+ assert callable (converter .process_image )
43+
44+ def test_process_image_with_invalid_path (self ):
45+ """Test process_image with non-existent file returns False"""
46+ converter = rawtoaces .ImageConverter ()
47+ result = converter .process_image ("/nonexistent/file.txt" )
48+ assert result is False
49+
50+ result = converter .process_image ("" )
51+ assert result is False
52+
53+
54+ class TestSettings :
55+ """Test cases for the ImageConverter.Settings class"""
56+
57+ def test_settings_creation (self ):
58+ """Test that Settings can be instantiated"""
59+ converter = rawtoaces .ImageConverter ()
60+ settings = converter .settings
61+ assert settings is not None
62+ assert isinstance (settings , rawtoaces .ImageConverter .Settings )
63+
64+ def test_settings_direct_creation (self ):
65+ """Test that Settings can be created directly"""
66+ settings = rawtoaces .ImageConverter .Settings ()
67+ assert settings is not None
68+ assert isinstance (settings , rawtoaces .ImageConverter .Settings )
69+
70+
71+ if __name__ == "__main__" :
72+ pytest .main ([__file__ ])
0 commit comments