Skip to content

Commit 5bc7de8

Browse files
committed
Add test progress delete.
1 parent 8ffb331 commit 5bc7de8

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from dash import Dash, Input, Output, State, html, clientside_callback
2+
import time
3+
4+
from tests.integration.long_callback.utils import get_long_callback_manager
5+
6+
long_callback_manager = get_long_callback_manager()
7+
handle = long_callback_manager.handle
8+
9+
app = Dash(__name__, long_callback_manager=long_callback_manager)
10+
11+
app.layout = html.Div(
12+
[
13+
html.Button("Start", id="start"),
14+
html.Div(id="output"),
15+
html.Div(id="progress-output"),
16+
html.Div(0, id="progress-counter"),
17+
]
18+
)
19+
20+
clientside_callback(
21+
"function(_, previous) { return parseInt(previous) + 1;}",
22+
Output("progress-counter", "children"),
23+
Input("progress-output", "children"),
24+
State("progress-counter", "children"),
25+
prevent_initial_call=True,
26+
)
27+
28+
29+
@app.callback(
30+
Output("output", "children"),
31+
Input("start", "n_clicks"),
32+
progress=Output("progress-output", "children"),
33+
interval=200,
34+
background=True,
35+
prevent_initial_call=True,
36+
)
37+
def on_bg_progress(set_progress, _):
38+
set_progress("start")
39+
time.sleep(2)
40+
set_progress("stop")
41+
return "done"
42+
43+
44+
if __name__ == "__main__":
45+
app.run_server(debug=True)

tests/integration/long_callback/test_basic_long_callback.py

+9
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,12 @@ def test_lcbc013_unordered_state_input(dash_duo, manager):
531531
dash_duo.find_element("#click").click()
532532

533533
dash_duo.wait_for_text_to_equal("#output", "stored")
534+
535+
536+
def test_lcbc014_progress_delete(dash_duo, manager):
537+
with setup_long_callback_app(manager, "app_progress_delete") as app:
538+
dash_duo.start_server(app)
539+
dash_duo.find_element("#start").click()
540+
dash_duo.wait_for_text_to_equal("#output", "done")
541+
542+
assert dash_duo.find_element("#progress-counter").text == "2"

0 commit comments

Comments
 (0)