Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Truncate InvalidCallbackReturnValue size - test
Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
  • Loading branch information
stdedos committed Nov 13, 2023
commit 587fa9dcbc90fa60490987a985a8e2acf96e36f7
85 changes: 84 additions & 1 deletion tests/integration/devtools/test_devtools_error_handling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: UTF-8 -*-
from dash import Dash, Input, Output, html, dcc
from dash import _validate, Dash, Input, Output, html, dcc
from dash.exceptions import PreventUpdate


Expand Down Expand Up @@ -260,3 +260,86 @@ def update_outputs(n_clicks):
dash_duo.wait_for_text_to_equal(dash_duo.devtools_error_count_locator, "1")
dash_duo.find_element(".test-devtools-error-toggle").click()
dash_duo.percy_snapshot("devtools - multi output Python exception - open")


def test_dveh006_truncate_callback(dash_duo):
app = Dash(__name__)

from dataclasses import dataclass
from typing import List, Dict, Any

@dataclass
class GenericItemA:
attribute_1: int
attribute_2: str

@dataclass
class GenericItemB:
key: str
value: List[str]

@dataclass
class GenericItemC:
identifier: int
description: str

@dataclass
class GenericOptions:
option_key: str
option_value: Any

@dataclass
class GenericDataModel:
ItemListA: List[GenericItemA]
SingleItemB: GenericItemB
NestedItemListC: List[List[GenericItemC]]
Options: GenericOptions
Metadata: Dict
AdditionalInfo: Any

app.layout = html.P(id="output")

@app.callback(Output("output", "children"), Input("url", "href"))
def get_width(_):
item_list_a = [
GenericItemA(attribute_1=123, attribute_2="Alpha"),
GenericItemA(attribute_1=456, attribute_2="Beta")
]

single_item_b = GenericItemB(key="Key1", value=["Item1", "Item2"])

nested_item_list_c = [
[GenericItemC(identifier=101, description="Description1")],
[GenericItemC(identifier=102, description="Description2")]
]

generic_options = GenericOptions(option_key="Option1", option_value="Value1")

generic_metadata = {"meta_key": "meta_value"}

additional_info = "Generic information"

# Creating an instance of GenericDataModel
generic_data_model = GenericDataModel(
ItemListA=item_list_a,
SingleItemB=single_item_b,
NestedItemListC=nested_item_list_c,
Options=generic_options,
Metadata=generic_metadata,
AdditionalInfo=additional_info
)

return generic_data_model

dash_duo.start_server(
app,
debug=True,
use_reloader=False,
use_debugger=True,
dev_tools_hot_reload=False,
)

dash_duo.find_element(".dash-debug-menu").click()
dash_duo.wait_for_text_to_equal(dash_duo.devtools_error_count_locator, "1")

assert len(get_error_html(dash_duo, 0)) == _validate.TRUNCATE_AT