forked from plotly/colorlover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
57 lines (47 loc) · 1.71 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import unittest
import colorlover as cl
class UsageTests(unittest.TestCase):
def test_scales(self):
scales = cl.scales['3']['div']['RdYlBu']
self.assertEqual(
scales,
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)'])
def test_to_numeric(self):
scales = cl.to_numeric(cl.scales['3']['div']['RdYlBu'])
self.assertEqual(
scales,
[(252, 141, 89),
(255, 255, 191), (145, 191, 219)]
)
def test_to_hsl(self):
scales = cl.to_hsl(cl.scales['3']['div']['RdYlBu'])
self.assertEqual(
scales,
['hsl(19, 96%, 67%)', 'hsl(60, 100%, 87%)',
'hsl(203, 51%, 71%)']
)
def test_to_rgb(self):
scales = cl.to_rgb(cl.scales['3']['div']['RdYlBu'])
self.assertEqual(
scales,
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']
)
def test_to_html(self):
html = cl.to_html(cl.scales['3']['div']['RdYlBu'])
self.assertEqual(
html,
('<div style="background-color:rgb(252,141,89);'
'height:20px;width:20px;display:inline-block;"></div>'
'<div style="background-color:rgb(255,255,191);'
'height:20px;width:20px;display:inline-block;"></div>'
'<div style="background-color:rgb(145,191,219);'
'height:20px;width:20px;display:inline-block;"></div>')
)
def test_flipper(self):
flipped = cl.flipper()['div']['3']['RdYlBu']
self.assertEqual(
flipped,
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']
)
if __name__ == '__main__':
unittest.main()