(dash_duo)
| 242 | |
| 243 | |
| 244 | def test_cbwc003_same_keys(dash_duo): |
| 245 | app = Dash(__name__, suppress_callback_exceptions=True) |
| 246 | |
| 247 | app.layout = html.Div( |
| 248 | [ |
| 249 | html.Button("Add Filter", id="add-filter", n_clicks=0), |
| 250 | html.Div(id="container", children=[]), |
| 251 | ] |
| 252 | ) |
| 253 | |
| 254 | @app.callback( |
| 255 | Output("container", "children"), |
| 256 | [Input("add-filter", "n_clicks")], |
| 257 | [State("container", "children")], |
| 258 | ) |
| 259 | def display_dropdowns(n_clicks, children): |
| 260 | new_element = html.Div( |
| 261 | [ |
| 262 | dcc.Dropdown( |
| 263 | id={"type": "dropdown", "index": n_clicks}, |
| 264 | options=[ |
| 265 | {"label": i, "value": i} for i in ["NYC", "MTL", "LA", "TOKYO"] |
| 266 | ], |
| 267 | ), |
| 268 | html.Div(id={"type": "output", "index": n_clicks}), |
| 269 | ] |
| 270 | ) |
| 271 | return children + [new_element] |
| 272 | |
| 273 | @app.callback( |
| 274 | Output({"type": "output", "index": MATCH}, "children"), |
| 275 | [Input({"type": "dropdown", "index": MATCH}, "value")], |
| 276 | [State({"type": "dropdown", "index": MATCH}, "id")], |
| 277 | ) |
| 278 | def display_output(value, id): |
| 279 | return html.Div("Dropdown {} = {}".format(id["index"], value)) |
| 280 | |
| 281 | dash_duo.start_server(app) |
| 282 | dash_duo.wait_for_text_to_equal("#add-filter", "Add Filter") |
| 283 | dash_duo.select_dcc_dropdown( |
| 284 | '#\\{\\"index\\"\\:0\\,\\"type\\"\\:\\"dropdown\\"\\}', "LA" |
| 285 | ) |
| 286 | dash_duo.wait_for_text_to_equal( |
| 287 | '#\\{\\"index\\"\\:0\\,\\"type\\"\\:\\"output\\"\\}', "Dropdown 0 = LA" |
| 288 | ) |
| 289 | dash_duo.find_element("#add-filter").click() |
| 290 | dash_duo.select_dcc_dropdown( |
| 291 | '#\\{\\"index\\"\\:1\\,\\"type\\"\\:\\"dropdown\\"\\}', "MTL" |
| 292 | ) |
| 293 | dash_duo.wait_for_text_to_equal( |
| 294 | '#\\{\\"index\\"\\:1\\,\\"type\\"\\:\\"output\\"\\}', "Dropdown 1 = MTL" |
| 295 | ) |
| 296 | dash_duo.wait_for_text_to_equal( |
| 297 | '#\\{\\"index\\"\\:0\\,\\"type\\"\\:\\"output\\"\\}', "Dropdown 0 = LA" |
| 298 | ) |
| 299 | dash_duo.wait_for_no_elements(dash_duo.devtools_error_count_locator) |
| 300 | |
| 301 |
nothing calls this directly
no test coverage detected
searching dependent graphs…