From a4196c602f879dcc5f35a0eba712bde8b1646792 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 21 Feb 2018 20:07:50 -0500 Subject: [PATCH 1/7] add flowtype integration test sanity check for https://github.com/plotly/dash/pull/207 --- dev-requirements.txt | 1 + tests/test_integration.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index 666112e921..7bb4abd893 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,6 @@ dash_core_components>=0.4.0 dash_html_components>=0.5.0 +dash_flow_example dash_renderer percy selenium diff --git a/tests/test_integration.py b/tests/test_integration.py index 9882572e56..93db26d4e5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,6 +1,7 @@ from multiprocessing import Value import dash_html_components as html import dash_core_components as dcc +import dash_flow_example from dash import Dash from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate @@ -112,3 +113,37 @@ def callback2(value): self.assertEqual(output2.text, initial_output) assert_clean_console(self) + + def test_flow_component(self): + app.layout = html.Div([ + dash_flow_example.ExampleReactComponent( + id='react', + value='my-value', + label='react component' + ), + dash_flow_example.ExampleFlowComponent( + id='flow', + value='my-value', + label='flow component' + ), + html.Hr(), + html.Div(id='output') + ]) + + @app.callback(Output('output', 'children'), + [Input('react', 'value'), Input('flow', 'value')]) + def display_output(react_value, flow_value): + return html.Div([ + 'You have entered {} and {}'.format(react_value, flow_value), + html.Hr(), + html.Label('Flow Component Docstring'), + html.Pre(dash_flow_example.ExampleFlowComponent.__doc__), + html.Hr(), + html.Label('React PropTypes Component Docstring'), + html.Pre(dash_flow_example.ExampleReactComponent.__doc__), + html.Div(id='waitfor') + ]) + + self.startServer(app) + self.wait_for_element_by_id('waitfor') + self.percy_snapshot(name='flowtype') From 808564723443844fe73456133e8fba4cb697385a Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 21 Feb 2018 20:08:04 -0500 Subject: [PATCH 2/7] white space --- tests/test_integration.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 93db26d4e5..068eddac86 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -66,13 +66,13 @@ def update_output(value): ) assert_clean_console(self) - + def test_aborted_callback(self): """Raising PreventUpdate prevents update and triggering dependencies""" - + initial_input = 'initial input' initial_output = 'initial output' - + app = Dash(__name__) app.layout = html.Div([ dcc.Input(id='input', value=initial_input), @@ -82,7 +82,7 @@ def test_aborted_callback(self): callback1_count = Value('i', 0) callback2_count = Value('i', 0) - + @app.callback(Output('output1', 'children'), [Input('input', 'value')]) def callback1(value): callback1_count.value = callback1_count.value + 1 @@ -100,7 +100,7 @@ def callback2(value): input_.clear() input_.send_keys('x') output1 = self.wait_for_element_by_id('output1') - output2 = self.wait_for_element_by_id('output2') + output2 = self.wait_for_element_by_id('output2') # callback1 runs twice (initial page load and through send_keys) self.assertEqual(callback1_count.value, 2) @@ -111,7 +111,7 @@ def callback2(value): # double check that output1 and output2 children were not updated self.assertEqual(output1.text, initial_output) self.assertEqual(output2.text, initial_output) - + assert_clean_console(self) def test_flow_component(self): From 6da3b7bf5aed90421d72d19817e9f00a866c671e Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 21 Feb 2018 20:14:16 -0500 Subject: [PATCH 3/7] add screenshot test to aborted example --- tests/test_integration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_integration.py b/tests/test_integration.py index 068eddac86..d17b53b660 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -114,6 +114,8 @@ def callback2(value): assert_clean_console(self) + self.percy_snapshot(name='aborted') + def test_flow_component(self): app.layout = html.Div([ dash_flow_example.ExampleReactComponent( From 1d2babddc009ad5bbd410a0bf7a84666dc16e24d Mon Sep 17 00:00:00 2001 From: Chris Parmer Date: Wed, 21 Feb 2018 20:58:38 -0500 Subject: [PATCH 4/7] lock down version of the flow component --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 7bb4abd893..8a7dc9b215 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,6 @@ dash_core_components>=0.4.0 dash_html_components>=0.5.0 -dash_flow_example +dash_flow_example==0.0.2 dash_renderer percy selenium From 7f6ac9e2b38438f1ef592bdc77d36e58923a2731 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 21 Feb 2018 20:59:58 -0500 Subject: [PATCH 5/7] missing declaration --- tests/test_integration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_integration.py b/tests/test_integration.py index d17b53b660..3f975529ac 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -117,6 +117,8 @@ def callback2(value): self.percy_snapshot(name='aborted') def test_flow_component(self): + app = dash.Dash() + app.layout = html.Div([ dash_flow_example.ExampleReactComponent( id='react', From 6db68c9d9efc875b14ff3adf7ba15ebf34b52d94 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 21 Feb 2018 21:03:40 -0500 Subject: [PATCH 6/7] use the convention --- tests/test_integration.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index 3f975529ac..034d83c65b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -2,7 +2,7 @@ import dash_html_components as html import dash_core_components as dcc import dash_flow_example -from dash import Dash +import dash from dash.dependencies import Input, Output from dash.exceptions import PreventUpdate from .IntegrationTests import IntegrationTests @@ -19,7 +19,7 @@ def wait_for_element_by_id(id): self.wait_for_element_by_id = wait_for_element_by_id def test_simple_callback(self): - app = Dash(__name__) + app = dash.Dash(__name__) app.layout = html.Div([ dcc.Input( id='input', @@ -73,7 +73,7 @@ def test_aborted_callback(self): initial_input = 'initial input' initial_output = 'initial output' - app = Dash(__name__) + app = dash.Dash(__name__) app.layout = html.Div([ dcc.Input(id='input', value=initial_input), html.Div(initial_output, id='output1'), From a4a192ff3d745882bfd2ea024cf2063c17f4311f Mon Sep 17 00:00:00 2001 From: Chris Parmer Date: Wed, 21 Feb 2018 21:09:29 -0500 Subject: [PATCH 7/7] update to latest flow --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 8a7dc9b215..f78b7c60e4 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,6 @@ dash_core_components>=0.4.0 dash_html_components>=0.5.0 -dash_flow_example==0.0.2 +dash_flow_example==0.0.3 dash_renderer percy selenium