MCPcopy
hub / github.com/plotly/dash / test_async_cbsc001_simple_callback

Function test_async_cbsc001_simple_callback

tests/async_tests/test_async_callbacks.py:33–70  ·  view source on GitHub ↗
(dash_duo)

Source from the content-addressed store, hash-verified

31
32@flaky.flaky(max_runs=3)
33def test_async_cbsc001_simple_callback(dash_duo):
34 if not is_dash_async():
35 return
36 lock = Lock()
37
38 app = Dash(__name__)
39 app.layout = html.Div(
40 [
41 dcc.Input(id="input", value="initial value"),
42 html.Div(html.Div([1.5, None, "string", html.Div(id="output-1")])),
43 ]
44 )
45 call_count = Value("i", 0)
46
47 @app.callback(Output("output-1", "children"), [Input("input", "value")])
48 async def update_output(value):
49 with lock:
50 call_count.value = call_count.value + 1
51 return value
52
53 dash_duo.start_server(app)
54
55 dash_duo.wait_for_text_to_equal("#output-1", "initial value")
56
57 input_ = dash_duo.find_element("#input")
58 dash_duo.clear_input(input_)
59
60 for key in "hello world":
61 with lock:
62 input_.send_keys(key)
63
64 dash_duo.wait_for_text_to_equal("#output-1", "hello world")
65
66 assert call_count.value == 2 + len("hello world"), "initial count + each key stroke"
67
68 assert not dash_duo.redux_state_is_loading
69
70 assert dash_duo.get_logs() == []
71
72
73def test_async_cbsc002_callbacks_generating_children(dash_duo):

Callers

nothing calls this directly

Calls 8

is_dash_asyncFunction · 0.90
DashClass · 0.90
find_elementMethod · 0.80
clear_inputMethod · 0.80
send_keysMethod · 0.80
get_logsMethod · 0.80
start_serverMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…