import numpy as np
import os
from granatpy.naturalizer import GraNat

def test_granat_initialization_and_naturalize(tmp_path):
    # Create a random RGB image
    image = np.random.randint(0, 256, (10, 10, 3), dtype=np.uint8)
    
    # Initialize GraNat wrapper
    gn = GraNat(image)
    
    # Ensure attributes are initialized to None
    assert gn.result is None
    assert gn.nfs is None
    
    # Run the naturalization process
    gn.naturalize(show=False)
    
    # Check that attributes have been populated
    assert gn.result is not None
    assert gn.result.shape == (10, 10, 3)
    assert gn.nfs is not None and len(gn.nfs) == 3
    assert gn.psnrs is not None and len(gn.psnrs) == 3
    
    # Test saving
    output_path = tmp_path / "output.png"
    gn.save(str(output_path))
    assert os.path.exists(output_path)
