def test_color_range_to_from_dict(): """Test the to/from dict methods.""" color_range = ColorRange( [Color(0, 100, 0), Color(100, 200, 100)], [0, 1000]) color_range_dict = color_range.to_dict() new_color = ColorRange.from_dict(color_range_dict) assert new_color.to_dict() == color_range_dict
def test_color_range_from_dict(): """Test the from_dict method.""" sample_dict = { 'colors': [{ 'r': '0', 'g': '0', 'b': '0' }, { 'r': '0', 'g': '255', 'b': '100' }] } color_range = ColorRange.from_dict(sample_dict) assert isinstance(color_range, ColorRange) assert color_range[0] == Color(0, 0, 0) assert color_range[1] == Color(0, 255, 100)