Skip to content

Commit 5beab83

Browse files
committed
Add test legacy components.
1 parent 6e57b0b commit 5beab83

File tree

1 file changed

+57
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)