-
-
Notifications
You must be signed in to change notification settings - Fork 73
Issue 384 - Handling of None
data and columns props
#731
Changes from 6 commits
b505bf8
299c2c0
c2d870c
0c27fd3
f47a3d1
d93331d
5794b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
testpaths = tests/ | ||
addopts = -rsxX -vv | ||
log_format = %(asctime)s | %(levelname)s | %(name)s:%(lineno)d | %(message)s | ||
log_cli_level = ERROR | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import dash | ||
from dash.dependencies import Input, Output | ||
from dash.exceptions import PreventUpdate | ||
|
||
from dash_table import DataTable | ||
from dash_html_components import Button, Div | ||
|
||
|
||
def get_app(): | ||
app = dash.Dash(__name__) | ||
|
||
columns = [{"name": i, "id": i} for i in ["a", "b"]] | ||
data = [dict(a=1, b=2), dict(a=11, b=22)] | ||
|
||
app.layout = Div( | ||
[ | ||
Button(id="clear-table", children=["Clear table"]), | ||
DataTable(id="table", columns=columns, data=data), | ||
] | ||
) | ||
|
||
@app.callback( | ||
[Output("table", "data"), Output("table", "columns")], | ||
[Input("clear-table", "n_clicks")], | ||
) | ||
def clear_table(n_clicks): | ||
if n_clicks is None: | ||
raise PreventUpdate | ||
|
||
nonlocal columns, data | ||
|
||
return (data, columns) if n_clicks % 2 == 0 else (None, None) | ||
|
||
return app | ||
|
||
|
||
def test_empt001_clear_(test): | ||
test.start_server(get_app()) | ||
|
||
target = test.table("table") | ||
|
||
assert target.is_ready() | ||
assert len(test.driver.find_elements_by_css_selector("tr")) == 3 | ||
test.driver.find_element_by_css_selector("#clear-table").click() | ||
assert target.is_ready() | ||
assert len(test.driver.find_elements_by_css_selector("tr")) == 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once the callback returns, the table should (1) load successfully and get to the ready state, (2) should contain no rows. TDD'ed locally, can undo redo the fix in the PR if we'd rather have the demonstration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with not seeing the test fail on CI - I assume we're all running our own tests with the fix disabled. But it would be nice to have this test check for the proper number of Also, given that you have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for DCC - accelerates
-k
test runsplotly/dash-core-components#740