@@ -312,6 +312,32 @@ def test_get_color_palette_source_remote_exists(self, palette_from_remote_mock):
312312 )
313313 self .assertEqual (palette_fake , actual_palette )
314314
315+ @patch ('hybig.color_utility.get_remote_palette_from_source' )
316+ def test_get_color_palette_with_ndv (self , get_remote_palette_from_source_mock ):
317+ """Test get_color_palette with dataset that has nodata values."""
318+ get_remote_palette_from_source_mock .side_effect = HyBIGNoColorInformation ('No color in source' )
319+
320+ ds = Mock (DatasetReader )
321+ test_colormap = {
322+ 100 : (255 , 0 , 0 , 255 ),
323+ 200 : (0 , 255 , 0 , 255 )
324+ }
325+ ds .colormap .return_value = test_colormap .copy ()
326+
327+ # Mock the get_nodatavals function to return a tuple with a nodata value
328+ # that matches one of our colormap keys
329+ ds .get_nodatavals .return_value = (100 ,)
330+
331+ actual_palette = get_color_palette (ds , None , None )
332+
333+ get_remote_palette_from_source_mock .assert_called_once ()
334+ ds .colormap .assert_called_once_with (1 )
335+ ds .get_nodatavals .assert_called_once ()
336+
337+ # Compare the actual and expected palettes
338+ self .assertEqual (actual_palette .get_color (200 ), encode_color (0 , 255 , 0 , 255 ))
339+ self .assertEqual (actual_palette .get_color ('nv' ), encode_color (255 , 0 , 0 , 255 ))
340+
315341 def test_convert_colormap_to_palette_3bands (self ):
316342 input_colormap = {
317343 5 : (255 , 0 , 0 ), # red
0 commit comments