Skip to content

Commit

Permalink
Enable new feature in echarts-china-cities-js: 370 city contours (pye…
Browse files Browse the repository at this point in the history
…charts#1111)

* ✨ introduce shape only geojson shapes

* 💚 fix broken unit test

* Fix: test

* Format: code
  • Loading branch information
chfw authored and chenjiandongx committed May 14, 2019
1 parent 755afe4 commit d763873
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyecharts/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def register_url(asset_url: str):
file_name = contents["FILE_MAP"][pinyin]
files[name] = [file_name, "js"]

EXTRA[contents["GITHUB_URL"] + "/"] = files
js_file_prefix = f'{contents["GITHUB_URL"]}/{contents["JS_FOLDER"]}/'
EXTRA[js_file_prefix] = files


def register_files(asset_files: dict):
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/registry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"JUPYTER_URL": "/nbextensions/echarts-china-cities-js",
"GITHUB_URL": "https://echarts-maps.github.io/echarts-china-cities-js",
"JUPYTER_ENTRY": "echarts-china-cities-js/index",
"JS_FOLDER": "js",
"GEOJSON_FOLDER": "geojson",
"PINYIN_MAP": {
"安庆": "an1_qing4"
},
"FILE_MAP": {
"an1_qing4": "shape-with-internal-borders/an1_hui1_an1_qing4"
}
}
24 changes: 24 additions & 0 deletions test/test_datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from unittest.mock import patch

from nose.tools import eq_

from pyecharts.datasets import EXTRA, register_url


@patch("pyecharts.datasets.urllib.request.urlopen")
def test_register_url(fake):
current_path = os.path.dirname(__file__)
with open(
os.path.join(current_path, "fixtures", "registry.json"), encoding="utf8"
) as f:
fake.return_value = f
register_url("fake_url")
eq_(
EXTRA,
{
"https://echarts-maps.github.io/echarts-china-cities-js/js/": {
"安庆": ["shape-with-internal-borders/an1_hui1_an1_qing4", "js"]
}
},
)

0 comments on commit d763873

Please sign in to comment.