forked from pyecharts/pyecharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_line.py
68 lines (58 loc) · 1.98 KB
/
test_line.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
63
64
65
66
67
68
from unittest.mock import patch
from nose.tools import assert_equal, assert_in
from pyecharts import options as opts
from pyecharts.charts import Line
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_bar_base(fake_writer):
c = (
Line()
.add_xaxis(["A", "B", "C"])
.add_yaxis("series0", [1, 2, 4])
.add_yaxis("series1", [2, 3, 6])
)
c.render()
_, content = fake_writer.call_args[0]
assert_equal(c.theme, "white")
assert_equal(c.renderer, "canvas")
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_set_global_opts(fake_writer):
test_type, test_range = "test_type", [-10001, 10001]
c = (
Line()
.set_global_opts(
xaxis_opts=opts.AxisOpts(is_inverse=True),
datazoom_opts=opts.DataZoomOpts(type_=test_type),
visualmap_opts=opts.VisualMapOpts(type_="size", range_size=test_range),
)
.add_xaxis(["A", "B", "C"])
.add_yaxis("series0", [1, 2, 4])
.add_yaxis("series1", [2, 3, 6])
)
c.render()
_, content = fake_writer.call_args[0]
assert_in('"inverse": true', content)
assert_in("test_type", content)
assert_in("-10001", content)
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_data_label_none_animation_opts(fake_writer):
c = (
Line()
.add_xaxis(["A", "B", "C"])
.add_yaxis("series0", [1, 2, 4], is_hover_animation=False)
.add_yaxis("series1", [2, 3, 6], is_hover_animation=False)
)
c.render()
_, content = fake_writer.call_args[0]
assert_in("hoverAnimation", content)
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_line_opts_with_zlevel_z(fake_writer):
c = (
Line()
.add_xaxis(["A", "B", "C"])
.add_yaxis("series0", [1, 2, 4])
.add_yaxis("series1", [2, 3, 6], z_level=2, z=1)
)
c.render()
_, content = fake_writer.call_args[0]
assert_in("zlevel", content)
assert_in("z", content)