def test_parse_color_match(self): rgba = parse_color([ "match", [ "get", "type" ], "Air Transport", "#e6e6e6", "Education", "#f7eaca", "hsla(28, 76%, 67%, 0.5)" ]) expected = """if ("type" is not null and "type" = 'Air Transport', '#e6e6e6', if ("type" is not null and "type" = 'Education', '#f7eaca', '235,167,107,128'))""" self.assertEqual(expected, rgba)
def test_parse_rgb(self): rgba = parse_color("rgb(1,2,3)") self.assertEqual("1,2,3,255", rgba)
def test_parse_short_hex(self): rgba = parse_color("#abc") self.assertEqual("170,187,204", rgba)
def test_parse_hex(self): rgba = parse_color("#ffff0c") self.assertEqual("#ffff0c", rgba)
def test_parse_hex_alpha(self): rgba = parse_color("#ffff0c32") self.assertEqual("255,255,12,50", rgba)
def test_parse_hsla(self): rgba = parse_color("hsla(28, 76%, 67%, 0.5)") self.assertEqual("235,167,107,128", rgba)
def test_parse_hsl(self): rgba = parse_color("hsl(28, 76%, 67%)") self.assertEqual("235,167,107,255", rgba)
def test_parse_rgba(self): rgba = parse_color("rgba(1, 2, 3, 0.5)") self.assertEqual("1,2,3,128", rgba)