This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathtest_graph_basics.py
83 lines (72 loc) · 2.44 KB
/
test_graph_basics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import pytest
import pandas as pd
import numpy as np
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
import dash.testing.wait as wait
def test_grbs001_graph_without_ids(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Graph(className="graph-no-id-1"),
dcc.Graph(className="graph-no-id-2"),
]
)
dash_duo.start_server(app)
assert not dash_duo.wait_for_element(".graph-no-id-1").get_attribute(
"id"
), "the graph should contain no more auto-generated id"
assert not dash_duo.wait_for_element(".graph-no-id-2").get_attribute(
"id"
), "the graph should contain no more auto-generated id"
@pytest.mark.DCC608
def test_grbs002_wrapped_graph_has_no_infinite_loop(dash_duo):
df = pd.DataFrame(np.random.randn(50, 50))
figure = {
"data": [
{"x": df.columns, "y": df.index, "z": df.values, "type": "heatmap"}
],
"layout": {"xaxis": {"scaleanchor": "y"}},
}
app = dash.Dash(__name__)
app.layout = html.Div(
style={
"backgroundColor": "red",
"height": "100vmin",
"width": "100vmin",
"overflow": "hidden",
"position": "relative",
},
children=[
dcc.Loading(
children=[
dcc.Graph(
id="graph",
figure=figure,
style={
"position": "absolute",
"top": 0,
"left": 0,
"backgroundColor": "blue",
"width": "100%",
"height": "100%",
"overflow": "hidden",
},
)
]
)
],
)
@app.callback(Output("graph", "figure"), [Input("graph", "relayoutData")])
def selected_df_figure(selection):
figure["data"][0]["x"] = df.columns
figure["data"][0]["y"] = df.index
figure["data"][0]["z"] = df.values
return figure
dash_duo.start_server(app)
wait.until(lambda: dash_duo.driver.title == "Dash", timeout=2)
assert (
len({dash_duo.driver.title for _ in range(20)}) == 1
), "after the first update, there should contain no extra Updating..."