@@ -66,3 +66,81 @@ def test_from_js_literal(input_files, input_filename, expected_filename, as_file
6666 expected_filename ,
6767 as_file ,
6868 error )
69+
70+
71+
72+ @pytest .mark .parametrize ('json_str, expected_modules, error' , [
73+ ("""{
74+ "chart": {
75+ "type": "column"
76+ },
77+ "colors": null,
78+ "credits": false,
79+ "exporting": {
80+ "scale": 1
81+ },
82+ "series": [{
83+ "baseSeries": 1,
84+ "color": "#434343",
85+ "name": "Pareto",
86+ "tooltip": {
87+ "valueDecimals": 2,
88+ "valueSuffix": "%"
89+ },
90+ "type": "pareto",
91+ "yAxis": 1,
92+ "zIndex": 10
93+ }, {
94+ "color": "#7cb5ec",
95+ "data": [1, 23, 45, 54, 84, 13, 8, 7, 23, 1, 34, 6, 8, 99, 85, 23, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1],
96+ "name": "random-name",
97+ "type": "column",
98+ "zIndex": 2
99+ }],
100+ "title": {
101+ "text": "Random Name Pareto"
102+ },
103+ "tooltip": {
104+ "shared": true
105+ },
106+ "xAxis": {
107+ "categories": ["Something", "Something", "Something", "Something", "Something", "Something", "Hypovolemia", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something"],
108+ "crosshair": true,
109+ "labels": {
110+ "rotation": 90
111+ }
112+ },
113+ "yAxis": [{
114+ "title": {
115+ "text": "count"
116+ }
117+ }, {
118+ "labels": {
119+ "format": "{value}%"
120+ },
121+ "max": 100,
122+ "maxPadding": 0,
123+ "min": 0,
124+ "minPadding": 0,
125+ "opposite": true,
126+ "title": {
127+ "text": "accum percent"
128+ }
129+ }]
130+ }""" , ['highcharts' , 'modules/exporting' , 'modules/pareto' ], None ),
131+ ])
132+ def test_get_required_modules (json_str , expected_modules , error ):
133+ from highcharts_core .options import HighchartsOptions
134+ options = HighchartsOptions .from_json (json_str )
135+ chart = cls .from_options (options )
136+ if not error :
137+ result = chart .get_required_modules ()
138+ if expected_modules :
139+ assert len (result ) == len (expected_modules )
140+ for item in expected_modules :
141+ assert item in result
142+ else :
143+ assert result is None or len (result ) == 0
144+ else :
145+ with pytest .raises (error ):
146+ result = chart .get_required_modules ()
0 commit comments