Skip to content

Commit 100da72

Browse files
committed
Add test legacy components.
1 parent 6e57b0b commit 100da72

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from dash import Dash
2+
from dash.development.base_component import Component, _explicitize_args
3+
4+
# Import to load into registry.
5+
import dash_generator_test_component_standard # noqa: F401
6+
7+
8+
class PreCAPLegacyComponent(Component):
9+
"""A MyStandardComponent component.
10+
MyComponent description
11+
12+
Keyword arguments:
13+
14+
- id (string; optional):
15+
The id of the component.
16+
17+
- style (optional):
18+
The style.
19+
20+
- value (string; default ''):
21+
The value to display.
22+
23+
Note: due to the large number of props for this component,
24+
not all of them appear in the constructor signature, but
25+
they may still be used as keyword arguments."""
26+
27+
@_explicitize_args
28+
def __init__(self, id=Component.UNDEFINED, style=Component.UNDEFINED, **kwargs):
29+
self._prop_names = ["id", "style", "value"]
30+
self._type = "MyStandardComponent"
31+
self._namespace = "dash_generator_test_component_standard"
32+
self._valid_wildcard_attributes = []
33+
self.available_properties = ["id", "style", "value"]
34+
self.available_wildcard_properties = []
35+
_explicit_args = kwargs.pop("_explicit_args")
36+
_locals = locals()
37+
_locals.update(kwargs) # For wildcard attrs and excess named props
38+
args = {k: _locals[k] for k in _explicit_args if k != "children"}
39+
for k in []:
40+
if k not in args:
41+
raise TypeError("Required argument `" + k + "` was not specified.")
42+
super(PreCAPLegacyComponent, self).__init__(**args)
43+
44+
45+
def test_leg001_legacy_pre_component_as_props(dash_duo):
46+
app = Dash(__name__)
47+
48+
app.layout = PreCAPLegacyComponent(id="pre-cap", value="legacy")
49+
50+
dash_duo.start_server(app)
51+
52+
dash_duo.wait_for_text_to_equal("#pre-cap", "legacy")
53+
assert dash_duo.get_logs() == []

0 commit comments

Comments
 (0)