(dash_duo)
| 31 | |
| 32 | @flaky.flaky(max_runs=3) |
| 33 | def 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 | |
| 73 | def test_async_cbsc002_callbacks_generating_children(dash_duo): |
nothing calls this directly
no test coverage detected
searching dependent graphs…