Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 79cd678

Browse files
committed
Fix integration tests.
1 parent 8617d16 commit 79cd678

File tree

1 file changed

+7
-153
lines changed

1 file changed

+7
-153
lines changed

test/test_integration.py

+7-153
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import dash_html_components as html
1313
import dash_core_components as dcc
1414
import dash_table_experiments as dt
15-
from dash.exceptions import PreventUpdate
1615
from selenium import webdriver
1716
from selenium.webdriver.common.keys import Keys
1817
from selenium.common.exceptions import InvalidElementStateException
@@ -225,7 +224,7 @@ def test_gallery(self):
225224
dcc.Upload(),
226225

227226
html.Label('Horizontal Tabs'),
228-
dcc.Tabs(id="tabs", children=[
227+
dcc.Tabs(id="horizontal-tabs", children=[
229228
dcc.Tab(label='Tab one', className='test', style={'border': '1px solid magenta'}, children=[
230229
html.Div(['Test'])
231230
]),
@@ -255,7 +254,7 @@ def test_gallery(self):
255254
),
256255

257256
html.Label('Vertical Tabs'),
258-
dcc.Tabs(id="tabs1", vertical=True, children=[
257+
dcc.Tabs(id="tabs", vertical=True, children=[
259258
dcc.Tab(label='Tab one', children=[
260259
html.Div(['Test'])
261260
]),
@@ -457,123 +456,6 @@ def render_content(tab):
457456
time.sleep(2)
458457
self.assertEqual(tabs_content.text, 'Test content 1')
459458

460-
def test_tabs_with_children_undefined(self):
461-
app = dash.Dash(__name__)
462-
463-
app.layout = html.Div([
464-
html.H1('Dash Tabs component demo'),
465-
dcc.Tabs(id="tabs", value='tab-1'),
466-
html.Div(id='tabs-content')
467-
])
468-
469-
self.startServer(app=app)
470-
471-
self.snapshot('Tabs component with children undefined')
472-
473-
def test_tabs_render_without_selected(self):
474-
app = dash.Dash(__name__)
475-
476-
data = [
477-
{'id': 'one', 'value': 1},
478-
{'id': 'two', 'value': 2},
479-
]
480-
481-
482-
menu = html.Div([
483-
html.Div('one', id='one'),
484-
html.Div('two', id='two')
485-
])
486-
487-
tabs_one = html.Div([
488-
dcc.Tabs([
489-
dcc.Tab(dcc.Graph(id='graph-one'), label='tab-one-one'),
490-
])
491-
], id='tabs-one', style={'display': 'none'})
492-
493-
tabs_two = html.Div([
494-
dcc.Tabs([
495-
dcc.Tab(dcc.Graph(id='graph-two'), label='tab-two-one'),
496-
])
497-
], id='tabs-two', style={'display': 'none'})
498-
499-
500-
app.layout = html.Div([
501-
menu,
502-
tabs_one,
503-
tabs_two
504-
])
505-
506-
for i in ('one', 'two'):
507-
508-
@app.callback(Output('tabs-{}'.format(i), 'style'),
509-
[Input(i, 'n_clicks')])
510-
def on_click(n_clicks):
511-
if n_clicks is None:
512-
raise PreventUpdate
513-
514-
if n_clicks % 2 == 1:
515-
return {'display': 'block'}
516-
return {'display': 'none'}
517-
518-
519-
@app.callback(Output('graph-{}'.format(i), 'figure'),
520-
[Input(i, 'n_clicks')])
521-
def on_click(n_clicks):
522-
if n_clicks is None:
523-
raise PreventUpdate
524-
525-
return {
526-
'data': [
527-
{
528-
'x': [1,2,3,4],
529-
'y': [4,3,2,1]
530-
}
531-
]
532-
}
533-
534-
self.startServer(app=app)
535-
536-
button_one = self.wait_for_element_by_css_selector('#one')
537-
button_two = self.wait_for_element_by_css_selector('#two')
538-
539-
button_one.click()
540-
541-
self.snapshot("Tabs 1 rendered ")
542-
543-
button_two.click()
544-
time.sleep(1)
545-
546-
self.snapshot("Tabs 2 rendered ")
547-
548-
def test_tabs_without_value(self):
549-
app = dash.Dash(__name__)
550-
551-
app.layout = html.Div([
552-
html.H1('Dash Tabs component demo'),
553-
dcc.Tabs(id="tabs-example", children=[
554-
dcc.Tab(label='Tab One', value='tab-1-example'),
555-
dcc.Tab(label='Tab Two', value='tab-2-example'),
556-
]),
557-
html.Div(id='tabs-content-example')
558-
])
559-
560-
561-
@app.callback(Output('tabs-content-example', 'children'),
562-
[Input('tabs-example', 'value')])
563-
def render_content(tab):
564-
if tab == 'tab-1-example':
565-
return html.H3('Default selected Tab content 1')
566-
elif tab == 'tab-2-example':
567-
return html.H3('Tab content 2')
568-
569-
self.startServer(app=app)
570-
571-
default_tab_content = self.wait_for_element_by_css_selector('#tabs-content-example')
572-
573-
self.assertEqual(default_tab_content.text, 'Default selected Tab content 1')
574-
575-
self.snapshot('Tab 1 should be selected by default')
576-
577459
def test_location_link(self):
578460
app = dash.Dash(__name__)
579461

@@ -724,8 +606,6 @@ def display_page(pathname):
724606

725607
self.startServer(app=app)
726608

727-
time.sleep(2)
728-
729609
#callback is called twice when defined
730610
self.assertEqual(
731611
call_count.value,
@@ -750,7 +630,7 @@ def display_page(pathname):
750630
#test if callback is only fired once (offset of 2)
751631
self.assertEqual(
752632
call_count.value,
753-
3
633+
2 + 1
754634
)
755635

756636
def test_candlestick(self):
@@ -861,16 +741,17 @@ def _on_confirmed(submit_n_clicks, cancel_n_clicks,
861741
if not submit_n_clicks and not cancel_n_clicks:
862742
return ''
863743
count.value += 1
864-
if (submit_timestamp and cancel_timestamp is None) or\
865-
(submit_timestamp and cancel_timestamp):
744+
if (
745+
(submit_timestamp and not cancel_timestamp) or
746+
(submit_timestamp > cancel_timestamp)
747+
):
866748
return 'confirmed'
867749
else:
868750
return 'canceled'
869751

870752
self.startServer(app)
871753
self.snapshot(test_name + ' -> initial')
872754
button = self.wait_for_element_by_css_selector('#button')
873-
print(button)
874755

875756
button.click()
876757
time.sleep(1)
@@ -960,30 +841,3 @@ def on_click(n_clicks):
960841
time.sleep(2)
961842

962843
self.driver.switch_to.alert.accept()
963-
964-
def test_empty_graph(self):
965-
app = dash.Dash(__name__)
966-
967-
app.layout = html.Div([
968-
html.Button(id='click', children='Click me'),
969-
dcc.Graph(
970-
id='graph',
971-
figure={
972-
'data': [dict(x=[1, 2, 3], y=[1, 2, 3], type='scatter')]
973-
}
974-
)
975-
])
976-
977-
@app.callback(dash.dependencies.Output('graph', 'figure'),
978-
[dash.dependencies.Input('click', 'n_clicks')],
979-
[dash.dependencies.State('graph', 'figure')])
980-
def render_content(click, prev_graph):
981-
if click:
982-
return {}
983-
return prev_graph
984-
985-
self.startServer(app)
986-
button = self.wait_for_element_by_css_selector('#click')
987-
button.click()
988-
time.sleep(2) # Wait for graph to re-render
989-
self.snapshot('render-empty-graph')

0 commit comments

Comments
 (0)