forked from pyecharts/pyecharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sunburst.py
62 lines (55 loc) · 1.79 KB
/
test_sunburst.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
58
59
60
61
62
from unittest.mock import patch
from nose.tools import assert_equal
from pyecharts import options as opts
from pyecharts.charts import Sunburst
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_sunburst_base(fake_writer):
data = [
{
"name": "Grandpa",
"children": [
{
"name": "Uncle Leo",
"value": 15,
"children": [
{"name": "Cousin Jack", "value": 2},
{
"name": "Cousin Mary",
"value": 5,
"children": [{"name": "Jackson", "value": 2}],
},
{"name": "Cousin Ben", "value": 4},
],
},
{
"name": "Father",
"value": 10,
"children": [
{"name": "Me", "value": 5},
{"name": "Brother Peter", "value": 1},
],
},
],
},
{
"name": "Nancy",
"children": [
{
"name": "Uncle Nike",
"children": [
{"name": "Cousin Betty", "value": 1},
{"name": "Cousin Jenny", "value": 2},
],
}
],
},
]
c = Sunburst().add("Sunburst 演示数据", data)
c.render()
_, content = fake_writer.call_args[0]
assert_equal(c.theme, "white")
assert_equal(c.renderer, "canvas")
def test_sunburst_dataitem():
item_name = "test_data_item"
item = opts.SunburstItem(name=item_name)
assert_equal(item.opts.get("name"), item_name)