This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
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 #178 from plotly/129-obsolete-docs
Document discouraged elements, and fix ObjectEl data
- Loading branch information
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
"postbuild": "es-check es5 dash_html_components/*.js", | ||
"build:watch": "watch 'npm run build' src", | ||
"test:import": "python -m unittest tests.test_dash_import", | ||
"test:py": "python -m unittest tests.test_dash_html_components tests.test_integration", | ||
"test:py": "pytest --nopercyfinalize --headless tests/test_dash_html_components.py tests/test_integration.py", | ||
"test": "run-s -c test:py test:import lint" | ||
}, | ||
"author": "Chris Parmer <[email protected]>", | ||
|
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.
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.