Skip to content

Commit 587fa9d

Browse files
committed
Truncate InvalidCallbackReturnValue size - test
Signed-off-by: Stavros Ntentos <[email protected]>
1 parent 3ef0334 commit 587fa9d

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

tests/integration/devtools/test_devtools_error_handling.py

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: UTF-8 -*-
2-
from dash import Dash, Input, Output, html, dcc
2+
from dash import _validate, Dash, Input, Output, html, dcc
33
from dash.exceptions import PreventUpdate
44

55

@@ -260,3 +260,86 @@ def update_outputs(n_clicks):
260260
dash_duo.wait_for_text_to_equal(dash_duo.devtools_error_count_locator, "1")
261261
dash_duo.find_element(".test-devtools-error-toggle").click()
262262
dash_duo.percy_snapshot("devtools - multi output Python exception - open")
263+
264+
265+
def test_dveh006_truncate_callback(dash_duo):
266+
app = Dash(__name__)
267+
268+
from dataclasses import dataclass
269+
from typing import List, Dict, Any
270+
271+
@dataclass
272+
class GenericItemA:
273+
attribute_1: int
274+
attribute_2: str
275+
276+
@dataclass
277+
class GenericItemB:
278+
key: str
279+
value: List[str]
280+
281+
@dataclass
282+
class GenericItemC:
283+
identifier: int
284+
description: str
285+
286+
@dataclass
287+
class GenericOptions:
288+
option_key: str
289+
option_value: Any
290+
291+
@dataclass
292+
class GenericDataModel:
293+
ItemListA: List[GenericItemA]
294+
SingleItemB: GenericItemB
295+
NestedItemListC: List[List[GenericItemC]]
296+
Options: GenericOptions
297+
Metadata: Dict
298+
AdditionalInfo: Any
299+
300+
app.layout = html.P(id="output")
301+
302+
@app.callback(Output("output", "children"), Input("url", "href"))
303+
def get_width(_):
304+
item_list_a = [
305+
GenericItemA(attribute_1=123, attribute_2="Alpha"),
306+
GenericItemA(attribute_1=456, attribute_2="Beta")
307+
]
308+
309+
single_item_b = GenericItemB(key="Key1", value=["Item1", "Item2"])
310+
311+
nested_item_list_c = [
312+
[GenericItemC(identifier=101, description="Description1")],
313+
[GenericItemC(identifier=102, description="Description2")]
314+
]
315+
316+
generic_options = GenericOptions(option_key="Option1", option_value="Value1")
317+
318+
generic_metadata = {"meta_key": "meta_value"}
319+
320+
additional_info = "Generic information"
321+
322+
# Creating an instance of GenericDataModel
323+
generic_data_model = GenericDataModel(
324+
ItemListA=item_list_a,
325+
SingleItemB=single_item_b,
326+
NestedItemListC=nested_item_list_c,
327+
Options=generic_options,
328+
Metadata=generic_metadata,
329+
AdditionalInfo=additional_info
330+
)
331+
332+
return generic_data_model
333+
334+
dash_duo.start_server(
335+
app,
336+
debug=True,
337+
use_reloader=False,
338+
use_debugger=True,
339+
dev_tools_hot_reload=False,
340+
)
341+
342+
dash_duo.find_element(".dash-debug-menu").click()
343+
dash_duo.wait_for_text_to_equal(dash_duo.devtools_error_count_locator, "1")
344+
345+
assert len(get_error_html(dash_duo, 0)) == _validate.TRUNCATE_AT

0 commit comments

Comments
 (0)