1313def test_loaded_spatial_image_img_source ():
1414 image = Image .open ("tests/images/sample_image2.png" )
1515 spi_loaded = construct_spatial_image_class (image , is_url = False )
16-
16+
1717 assert isinstance (spi_loaded , LoadedSpatialImage )
1818 assert spi_loaded .img_source () is None
1919 assert spi_loaded .img_source (as_path = True ) is None
20-
20+
2121 np_image = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 )
2222 spi_loaded_np = construct_spatial_image_class (np_image )
23-
23+
2424 assert isinstance (spi_loaded_np , LoadedSpatialImage )
2525 assert spi_loaded_np .img_source () is None
2626 assert spi_loaded_np .img_source (as_path = True ) is None
@@ -29,26 +29,26 @@ def test_loaded_spatial_image_img_source():
2929def test_stored_spatial_image_img_source ():
3030 image_path = "tests/images/sample_image1.jpg"
3131 spi_stored = construct_spatial_image_class (image_path , is_url = False )
32-
32+
3333 assert isinstance (spi_stored , StoredSpatialImage )
34-
34+
3535 source_path = spi_stored .img_source ()
3636 assert isinstance (source_path , Path )
3737 assert image_path in str (source_path )
38-
38+
3939 source_str = spi_stored .img_source (as_path = True )
4040 assert isinstance (source_str , str )
4141 assert image_path in source_str
42-
42+
4343 assert str (source_path ) == str (spi_stored .path )
4444
4545
4646def test_remote_spatial_image_img_source ():
4747 image_url = "https://example.com/test_image.jpg"
4848 spi_remote = construct_spatial_image_class (image_url , is_url = True )
49-
49+
5050 assert isinstance (spi_remote , RemoteSpatialImage )
51-
51+
5252 source = spi_remote .img_source ()
5353 assert isinstance (source , str )
5454 assert source == image_url
@@ -57,17 +57,17 @@ def test_remote_spatial_image_img_source():
5757def test_remote_spatial_image_img_source_with_mock (monkeypatch ):
5858 image_url = "https://example.com/test_image.jpg"
5959 spi_remote = construct_spatial_image_class (image_url , is_url = True )
60-
60+
6161 assert isinstance (spi_remote , RemoteSpatialImage )
62-
62+
6363 # Mock the _download_image method to return a fixed path
6464 mock_path = Path ("/tmp/image.jpg" )
6565 monkeypatch .setattr (spi_remote , "_download_image" , lambda : mock_path )
66-
66+
6767 # Test with as_path=True (returns the cached path)
6868 source_path = spi_remote .img_source (as_path = True )
6969 assert source_path == str (mock_path )
70-
70+
7171 # Test default behavior returns URL
7272 assert spi_remote .img_source () == image_url
7373
0 commit comments