Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

Release 1.4.1
=========================================

* **BUGFIX**: Fixed incorrect cross-dependency inheritance in
``options/series_generator.create_series_obj()`` (#36)

---------------------


Release 1.4.0
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_maps/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.0'
__version__ = '1.4.1'
3 changes: 2 additions & 1 deletion highcharts_maps/options/series/series_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

from highcharts_maps import errors

from highcharts_core.options.series.base import SeriesBase

# Highcharts for Python series
from highcharts_maps.options.series.base import SeriesBase
from highcharts_maps.options.series.arcdiagram import ArcDiagramSeries
from highcharts_maps.options.series.area import AreaSeries
from highcharts_maps.options.series.area import AreaRangeSeries
Expand Down
153 changes: 153 additions & 0 deletions tests/options/chart/test_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,59 @@

STANDARD_PARAMS = [
({}, None),
({
'align_thresholds': True,
'align_ticks': True,
'allow_mutating_data': True,
'animation': False,
'background_color': '#fff',
'border_color': '#ccc',
'border_radius': 3,
'border_width': 1,
'class_name': 'some-class-name',
'color_count': 10,
'display_errors': True,
'events': {
'addSeries': """function(event) { return true;}""",
'afterPrint': """function(event) {return true;}""",
'click': """function(event) { return true; }""",
'selection': """function(event) { return true; }"""
},
'height': 120,
'ignore_hidden_series': False,
'inverted': False,
'margin': 20,
'number_formatter': """function(value) { return true; }""",
'pan_key': 'ctrl',
'panning': {
'enabled': True,
'type': 'x'
},
'parallel_coordinates': False,
'plot_background_color': '#ccc',
'plot_background_image': 'http://www.somewhere.com',
'plot_border_color': '#999',
'plot_border_width': 1,
'plot_shadow': False,
'polar': False,
'reflow': False,
'render_to': 'some-id',
'scrollable_plot_area': {
'minHeight': 120,
'minWidth': 300,
'opacity': 0.6,
'scrollPositionX': 0,
'scrollPositionY': 0
},
'selection_marker_fill': '#ccc',
'shadow': False,
'show_axes': True,
'spacing': [5, 5, 5, 5],
'style': 'style-string-goes-here',
'styled_mode': False,
'type': 'line',
'width': 50
}, None),
({
'align_thresholds': True,
'align_ticks': True,
Expand Down Expand Up @@ -64,6 +117,16 @@
'styled_mode': False,
'type': 'line',
'width': 50,
'zooming': {
'key': 'alt',
'mouse_wheel': {
'enabled': True,
'sensitivity': 1.5,
'type': 'xy'
},
'pinch_type': 'xy',
'single_touch': False
}
}, None),
]

Expand All @@ -90,6 +153,7 @@ def test_to_dict(kwargs, error):

@pytest.mark.parametrize('filename, as_file, error', [
('chart/chart/01.js', False, None),
('chart/chart/02.js', False, None),

('chart/chart/error-01.js',
False,
Expand All @@ -100,6 +164,7 @@ def test_to_dict(kwargs, error):
ValueError)),

('chart/chart/01.js', True, None),
('chart/chart/02.js', False, None),

('chart/chart/error-01.js',
True,
Expand All @@ -112,3 +177,91 @@ def test_to_dict(kwargs, error):
])
def test_from_js_literal(input_files, filename, as_file, error):
Class_from_js_literal(cls, input_files, filename, as_file, error)


@pytest.mark.parametrize('as_dict, as_js_literal, error', [
({
'marginRight': 124
}, False, None),
({
'type': 'bar',
'marginRight': 124,
'marginTop': 421,
'marginBottom': 321,
'marginLeft': 789,
'scrollablePlotArea': {
'minHeight': 1000,
'opacity': 1
}
}, False, None),

({
'marginRight': 124
}, True, None),
({
'type': 'bar',
'marginRight': 124,
'marginTop': 421,
'marginBottom': 321,
'marginLeft': 789,
'scrollablePlotArea': {
'minHeight': 1000,
'opacity': 1
}
}, True, None),
])
def test_bug124_margin_right(as_dict, as_js_literal, error):
if not error:
if not as_js_literal:
result = cls.from_dict(as_dict)
else:
as_str = str(as_dict)
result = cls.from_js_literal(as_str)
assert isinstance(result, cls) is True
if 'marginRight' in as_dict or 'margin_right' in as_dict:
assert result.margin_right == as_dict.get('marginRight', None)
if 'marginTop' in as_dict or 'margin_top' in as_dict:
assert result.margin_top == as_dict.get('marginTop', None)
if 'marginBottom' in as_dict or 'margin_bottom' in as_dict:
assert result.margin_bottom == as_dict.get('marginBottom', None)
if 'marginLeft' in as_dict or 'margin_left' in as_dict:
assert result.margin_left == as_dict.get('marginLeft', None)
else:
with pytest.raises(error):
if not as_js_literal:
result = cls.from_dict(as_dict)
else:
as_str = str(as_dict)
result = cls.from_js_literal(as_str)


@pytest.mark.parametrize('as_str, error', [
("""{
marginRight: 124
}""", None),
("""{type: 'bar',
marginRight: 124,
marginTop: 421,
marginBottom: 321,
marginLeft: 789,
scrollablePlotArea: {
minHeight: 1000,
opacity: 1
}
}""", None),
])
def test_bug124_margin_right_from_js_literal(as_str, error):
if not error:
result = cls.from_js_literal(as_str)
assert isinstance(result, cls) is True
if 'marginRight' in as_str or 'margin_right' in as_str:
assert result.margin_right is not None
if 'marginTop' in as_str or 'margin_top' in as_str:
assert result.margin_top is not None
if 'marginBottom' in as_str or 'margin_bottom' in as_str:
assert result.margin_bottom is not None
if 'marginLeft' in as_str or 'margin_left' in as_str:
assert result.margin_left is not None
else:
with pytest.raises(error):
result = cls.from_js_literal(as_str)
26 changes: 26 additions & 0 deletions tests/options/series/test_series_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest

from json.decoder import JSONDecodeError

from highcharts_core.options.series.base import SeriesBase as CoreSeriesBase
from highcharts_core.options.series.bar import BarSeries as CoreBarSeries
from highcharts_maps.options.series.base import SeriesBase as MapsSeriesBase
from highcharts_maps.options.series.bar import BarSeries as MapsBarSeries

from highcharts_maps.options.series.series_generator import create_series_obj


@pytest.mark.parametrize('cls, expected, error', [
(CoreBarSeries, True, None),
(MapsBarSeries, True, None),
])
def test_isinstance_check(cls, expected, error):
if not error:
item = cls()
result = create_series_obj(item)
assert isinstance(result, cls) is expected
assert isinstance(result, CoreSeriesBase) is expected
else:
item = cls()
with pytest.raises(error):
result = create_series_obj(item)