|
8 | 8 | from multiprocessing import Lock
|
9 | 9 | import time
|
10 | 10 | import json
|
| 11 | +import re |
11 | 12 |
|
12 | 13 | import flask
|
13 | 14 | import pandas as pd
|
@@ -1184,6 +1185,54 @@ def on_click(n_clicks):
|
1184 | 1185 | time.sleep(1)
|
1185 | 1186 | self.snapshot("Tabs 2 rendered ")
|
1186 | 1187 |
|
| 1188 | + # do some extra tests while we're here |
| 1189 | + # and have access to Graph and plotly.js |
| 1190 | + self.check_graph_config_shape() |
| 1191 | + self.check_plotlyjs() |
| 1192 | + |
| 1193 | + def check_plotlyjs(self): |
| 1194 | + # find plotly.js files in the dist folder, check that there's only one |
| 1195 | + all_dist = os.listdir(dcc.__path__[0]) |
| 1196 | + js_re = '^plotly-(.*)\.min\.js$' |
| 1197 | + plotlyjs_dist = [fn for fn in all_dist if re.match(js_re, fn)] |
| 1198 | + |
| 1199 | + self.assertEqual(len(plotlyjs_dist), 1) |
| 1200 | + |
| 1201 | + # check that the version matches what we see in the page |
| 1202 | + page_version = self.driver.execute_script('return Plotly.version;') |
| 1203 | + dist_version = re.match(js_re, plotlyjs_dist[0]).groups()[0] |
| 1204 | + self.assertEqual(page_version, dist_version) |
| 1205 | + |
| 1206 | + def check_graph_config_shape(self): |
| 1207 | + config_schema = self.driver.execute_script( |
| 1208 | + 'return Plotly.PlotSchema.get().config;' |
| 1209 | + ) |
| 1210 | + with open(os.path.join(dcc.__path__[0], 'metadata.json')) as meta: |
| 1211 | + graph_meta = json.load(meta)['src/components/Graph.react.js'] |
| 1212 | + config_prop_shape = graph_meta['props']['config']['type']['value'] |
| 1213 | + |
| 1214 | + ignored_config = [ |
| 1215 | + 'setBackground', |
| 1216 | + 'showSources', |
| 1217 | + 'logging', |
| 1218 | + 'globalTransforms', |
| 1219 | + 'role' |
| 1220 | + ] |
| 1221 | + |
| 1222 | + def crawl(schema, props): |
| 1223 | + for prop_name in props: |
| 1224 | + self.assertIn(prop_name, schema) |
| 1225 | + |
| 1226 | + for item_name, item in schema.items(): |
| 1227 | + if item_name in ignored_config: |
| 1228 | + continue |
| 1229 | + |
| 1230 | + self.assertIn(item_name, props) |
| 1231 | + if 'valType' not in item: |
| 1232 | + crawl(item, props[item_name]['value']) |
| 1233 | + |
| 1234 | + crawl(config_schema, config_prop_shape) |
| 1235 | + |
1187 | 1236 | def test_tabs_without_value(self):
|
1188 | 1237 | app = dash.Dash(__name__)
|
1189 | 1238 |
|
|
0 commit comments