📚 🔬 document and test the map extension feature

This commit is contained in:
chfw 2018-01-13 19:17:06 +00:00
parent 4456958755
commit 574b8bfc31
4 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,22 @@
@startuml
package "pyecharts" {
[python codes]
[jupyter-echarts]
[echarts-china-cities-js]
}
[pyecharts-cli]
cloud "github" {
[echarts-countries-js]
[echarts-united-kingdom-js]
}
[python codes] --> [jupyter-echarts] : embeds
[jupyter-echarts] --> [echarts-china-cities-js] : embeds
[python codes] ..> [echarts-countries-js] : reads
[python codes] ..> [echarts-united-kingdom-js] : reads
[pyecharts-cli] --> [echarts-countries-js] : installs
[pyecharts-cli] --> [echarts-united-kingdom-js] : installs
@enduml

View File

@ -9,7 +9,7 @@ JS_EXTENSION_REGISTRY = 'registry.json'
DEFAULT_TEMPLATE_DIR = get_resource_dir('templates')
DEFAULT_ECHARTS_LOCATION = os.path.join(
get_resource_dir('templates'), 'js', 'echarts')
get_resource_dir('templates'), 'js')
class JsExtension(object):

11
test/fixtures/registry.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"JUPYTER_URL": "/nbextensions/test-js",
"GITHUB_URL": "https://your.github.io/test-js/test-js",
"JUPYTER_ENTRY": "test-js/index",
"PINYIN_MAP": {
"ABC": "abc"
},
"FILE_MAP": {
"abc": "the_js_file_name"
}
}

28
test/test_js_extension.py Normal file
View File

@ -0,0 +1,28 @@
import os
from nose.tools import eq_
from pyecharts.js_extension import JsExtension
def produce_test_js_extension():
registry_path = os.path.join('.', 'fixtures')
return JsExtension(registry_path)
def test_get_js_library():
test_extension = produce_test_js_extension()
print(test_extension.registry)
actual = test_extension.get_js_library('abc')
eq_(actual, 'the_js_file_name')
def test_get_js_link():
test_extension = produce_test_js_extension()
actual = test_extension.get_js_link('abc')
eq_(actual, '/nbextensions/test-js/the_js_file_name.js')
def test_get_js_link():
test_extension = produce_test_js_extension()
actual = test_extension.get_js_link('abc')
eq_(actual, '/nbextensions/test-js/the_js_file_name.js')