Skip to content

Commit 44ac465

Browse files
authored
Flow integration test (#212)
* add flowtype integration test sanity check for #207 * white space * add screenshot test to aborted example
1 parent 8478942 commit 44ac465

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dash_core_components>=0.4.0
22
dash_html_components>=0.5.0
3+
dash_flow_example==0.0.3
34
dash_renderer
45
percy
56
selenium

tests/test_integration.py

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from multiprocessing import Value
22
import dash_html_components as html
33
import dash_core_components as dcc
4-
from dash import Dash
4+
import dash_flow_example
5+
import dash
56
from dash.dependencies import Input, Output
67
from dash.exceptions import PreventUpdate
78
from .IntegrationTests import IntegrationTests
@@ -18,7 +19,7 @@ def wait_for_element_by_id(id):
1819
self.wait_for_element_by_id = wait_for_element_by_id
1920

2021
def test_simple_callback(self):
21-
app = Dash(__name__)
22+
app = dash.Dash(__name__)
2223
app.layout = html.Div([
2324
dcc.Input(
2425
id='input',
@@ -65,14 +66,14 @@ def update_output(value):
6566
)
6667

6768
assert_clean_console(self)
68-
69+
6970
def test_aborted_callback(self):
7071
"""Raising PreventUpdate prevents update and triggering dependencies"""
71-
72+
7273
initial_input = 'initial input'
7374
initial_output = 'initial output'
74-
75-
app = Dash(__name__)
75+
76+
app = dash.Dash(__name__)
7677
app.layout = html.Div([
7778
dcc.Input(id='input', value=initial_input),
7879
html.Div(initial_output, id='output1'),
@@ -81,7 +82,7 @@ def test_aborted_callback(self):
8182

8283
callback1_count = Value('i', 0)
8384
callback2_count = Value('i', 0)
84-
85+
8586
@app.callback(Output('output1', 'children'), [Input('input', 'value')])
8687
def callback1(value):
8788
callback1_count.value = callback1_count.value + 1
@@ -99,7 +100,7 @@ def callback2(value):
99100
input_.clear()
100101
input_.send_keys('x')
101102
output1 = self.wait_for_element_by_id('output1')
102-
output2 = self.wait_for_element_by_id('output2')
103+
output2 = self.wait_for_element_by_id('output2')
103104

104105
# callback1 runs twice (initial page load and through send_keys)
105106
self.assertEqual(callback1_count.value, 2)
@@ -110,5 +111,43 @@ def callback2(value):
110111
# double check that output1 and output2 children were not updated
111112
self.assertEqual(output1.text, initial_output)
112113
self.assertEqual(output2.text, initial_output)
113-
114+
114115
assert_clean_console(self)
116+
117+
self.percy_snapshot(name='aborted')
118+
119+
def test_flow_component(self):
120+
app = dash.Dash()
121+
122+
app.layout = html.Div([
123+
dash_flow_example.ExampleReactComponent(
124+
id='react',
125+
value='my-value',
126+
label='react component'
127+
),
128+
dash_flow_example.ExampleFlowComponent(
129+
id='flow',
130+
value='my-value',
131+
label='flow component'
132+
),
133+
html.Hr(),
134+
html.Div(id='output')
135+
])
136+
137+
@app.callback(Output('output', 'children'),
138+
[Input('react', 'value'), Input('flow', 'value')])
139+
def display_output(react_value, flow_value):
140+
return html.Div([
141+
'You have entered {} and {}'.format(react_value, flow_value),
142+
html.Hr(),
143+
html.Label('Flow Component Docstring'),
144+
html.Pre(dash_flow_example.ExampleFlowComponent.__doc__),
145+
html.Hr(),
146+
html.Label('React PropTypes Component Docstring'),
147+
html.Pre(dash_flow_example.ExampleReactComponent.__doc__),
148+
html.Div(id='waitfor')
149+
])
150+
151+
self.startServer(app)
152+
self.wait_for_element_by_id('waitfor')
153+
self.percy_snapshot(name='flowtype')

0 commit comments

Comments
 (0)