1# coding=utf-8 2from color_randomize import Randomize 3from .test_inkex_extensions import ColorBaseCase 4 5class ColorRandomizeTest(ColorBaseCase): 6 effect_class = Randomize 7 python3_only = True 8 color_tests = [ 9 # "hsl(191, 122, 150)" = rgb(150, 100, 200) 10 ("none", "none"), 11 # The default ranges are set to 0, and thus the color and opacity should not change (except 12 # for rounding errors) 13 ("hsl(191, 122, 150)", "hsl(191, 122, 149)"), 14 # The user selected 0% values, and thus the color should not change. 15 ("hsl(191, 122, 150)", "hsl(191, 122, 149)", ['-y 0', '-t 0', '-m 0']), 16 # Random hue only. Saturation and lightness not changed. 17 ("hsl(191, 122, 150)", "hsl(201, 122, 149)", ['-y 50', '-t 0', '-m 0']), 18 # Random saturation only. Hue and lightness not changed. 19 ("hsl(191, 122, 150)", "hsl(191, 165, 149)", ['-y 0', '-t 50', '-m 0']), 20 # Random lightness only. Hue and saturation not changed. 21 ("hsl(191, 122, 150)", "hsl(190, 120, 194)", ['-y 0', '-t 0', '-m 50']), 22 # The maximum hsl values should be between 0 and 100% of their maximum 23 ("hsl(191, 122, 150)", "hsl(133, 134, 227)", ['-y 100', '-t 100', '-m 100']), 24 ] 25 26 opacity_tests = [ 27 (5, 5), 28 # The user selected 0% opacity range, and thus the opacity should not change. 29 (0.15, 0.15, ['-o 0']), 30 # The opacity value should be greater than 0 31 (0.0, 1.0, ['-o 100']), 32 # The opacity value should be lesser than 1 33 (1.0, 0.43, ['-o 100']), 34 # Other units are available 35 ('0.5', 0.654, ['-o 54']), 36 ] 37 38 def test_bad_opacity(self): 39 """Bad opacity error handled""" 40 self.effect.modify_opacity('opacity', 'hello') 41