forked from plotly/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request plotly#178 from plotly/129-obsolete-docs
Document discouraged elements, and fix ObjectEl data
- Loading branch information
1 parent
3dcc02a
commit 42a82dc
Showing
10 changed files
with
231 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
91 changes: 48 additions & 43 deletions
91
packages/dash-html-components/tests/test_dash_html_components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,48 @@ | ||
import unittest | ||
import dash_html_components | ||
|
||
|
||
class TestDashHtmlComponents(unittest.TestCase): | ||
def test_imports(self): | ||
with open('./scripts/data/elements.txt') as f: | ||
elements = [ | ||
s[0].upper() + s[1:] for s in | ||
f.read().split('\n') | ||
] | ||
elements += ['MapEl', 'ObjectEl'] | ||
for s in ['Map', 'Object']: | ||
elements.remove(s) | ||
|
||
print(dir(dash_html_components)) | ||
|
||
self.assertEqual( | ||
set([d for d in dir(dash_html_components) if d[0] != '_' and d[0] == d[0].capitalize()]), | ||
set(elements) | ||
) | ||
|
||
def test_sample_items(self): | ||
Div = dash_html_components.Div | ||
Img = dash_html_components.Img | ||
|
||
layout = Div( | ||
Div( | ||
Img(src='https://plotly.com/~chris/1638.png') | ||
), style={'color': 'red'} | ||
) | ||
|
||
self.assertEqual( | ||
repr(layout), | ||
''.join([ | ||
"Div(children=Div(Img(src='https://plotly.com/~chris/1638.png')), " | ||
"style={'color': 'red'})" | ||
]) | ||
) | ||
|
||
self.assertEqual( | ||
layout._namespace, 'dash_html_components' | ||
) | ||
import pytest | ||
import dash_html_components as html | ||
|
||
|
||
def test_imports(): | ||
with open("./scripts/data/elements.txt") as f: | ||
elements = [s[0].upper() + s[1:] for s in f.read().split("\n")] | ||
elements += ["MapEl", "ObjectEl"] | ||
for s in ["Map", "Object"]: | ||
elements.remove(s) | ||
|
||
dir_set = set( | ||
[ | ||
d | ||
for d in dir(html) | ||
if d[0] != "_" and d[0] == d[0].capitalize() | ||
] | ||
) | ||
assert dir_set == set(elements) | ||
|
||
|
||
def test_sample_items(): | ||
layout = html.Div( | ||
html.Div(html.Img(src="https://plotly.com/~chris/1638.png")), | ||
style={"color": "red"} | ||
) | ||
|
||
expected = ( | ||
"Div(children=Div(Img(src='https://plotly.com/~chris/1638.png')), " | ||
"style={'color': 'red'})" | ||
) | ||
assert repr(layout) == expected | ||
|
||
assert layout._namespace == "dash_html_components" | ||
|
||
|
||
def test_objectEl(): | ||
layout = html.ObjectEl(data="something", **{"data-x": "else"}) | ||
assert repr(layout) == "ObjectEl(data='something', data-x='else')" | ||
|
||
with pytest.raises(TypeError): | ||
html.ObjectEl(datax="something") | ||
|
||
|
||
def test_customDocs(): | ||
assert "CAUTION" in html.Script.__doc__[:100] | ||
assert "OBSOLETE" in html.Blink.__doc__[:100] | ||
assert "DEPRECATED" in html.Marquee.__doc__[:100] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.