-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathtest_basic_long_callback008.py
More file actions
63 lines (49 loc) · 2.1 KB
/
test_basic_long_callback008.py
File metadata and controls
63 lines (49 loc) · 2.1 KB
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
import sys
import pytest
from tests.background_callback.utils import setup_background_callback_app
@pytest.mark.skipif(
sys.version_info < (3, 7), reason="Python 3.6 long callbacks tests hangs up"
)
def test_lcbc008_long_callbacks_error(dash_duo, manager):
with setup_background_callback_app(manager, "app_error") as app:
dash_duo.start_server(
app,
debug=True,
use_reloader=False,
use_debugger=True,
dev_tools_hot_reload=False,
dev_tools_ui=True,
)
clicker = dash_duo.wait_for_element("#button")
def click_n_wait():
clicker.click()
dash_duo.wait_for_element("#button:disabled")
dash_duo.wait_for_element("#button:not([disabled])")
clicker.click()
dash_duo.wait_for_text_to_equal("#output", "Clicked 1 times")
click_n_wait()
dash_duo.wait_for_element(".dash-fe-error__title").click()
dash_duo.driver.switch_to.frame(dash_duo.find_element("iframe"))
assert (
"dash.exceptions.BackgroundCallbackError: "
"An error occurred inside a background callback:"
in dash_duo.wait_for_element(".errormsg").text
)
dash_duo.driver.switch_to.default_content()
click_n_wait()
dash_duo.wait_for_text_to_equal("#output", "Clicked 3 times")
click_n_wait()
dash_duo.wait_for_text_to_equal("#output", "Clicked 3 times")
click_n_wait()
dash_duo.wait_for_text_to_equal("#output", "Clicked 5 times")
def make_expect(n):
return [str(x) for x in range(1, n + 1)] + ["" for _ in range(n + 1, 4)]
multi = dash_duo.wait_for_element("#multi-output")
for i in range(1, 4):
with app.test_lock:
multi.click()
dash_duo.wait_for_element("#multi-output:disabled")
expect = make_expect(i)
dash_duo.wait_for_text_to_equal("#output-status", f"Updated: {i}")
for j, e in enumerate(expect):
assert dash_duo.find_element(f"#output{j + 1}").text == e