forked from pyecharts/pyecharts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_map.py
More file actions
37 lines (31 loc) · 1.09 KB
/
test_map.py
File metadata and controls
37 lines (31 loc) · 1.09 KB
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
from unittest.mock import patch
import simplejson as json
from nose.tools import assert_equal
from pyecharts import options as opts
from pyecharts.charts import Map
from pyecharts.faker import Faker
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_map_base(fake_writer):
c = Map().add(
"商家A", [list(z) for z in zip(Faker.provinces, Faker.values())], "china"
)
c.render()
_, content = fake_writer.call_args[0]
assert_equal(c.theme, "white")
assert_equal(c.renderer, "canvas")
def test_map_emphasis():
c = Map().add(
"商家A",
[list(z) for z in zip(Faker.provinces, Faker.values())],
"china",
emphasis_label_opts=opts.LabelOpts(is_show=False),
emphasis_itemstyle_opts=opts.ItemStyleOpts(
border_color="white", area_color="red"
),
)
options = json.loads(c.dump_options())
expected = {
"label": {"show": False, "position": "top", "margin": 8},
"itemStyle": {"borderColor": "white", "areaColor": "red"},
}
assert_equal(expected, options["series"][0]["emphasis"])