-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Specify version of plotly.js in CDN URL #2961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ed5058
feature/include_plotlyjs uses bundles js version, new cdn-latest option
adehad 49a777d
fix other tests that are broken by new 'cdn' option behaviour
adehad 5553f89
make cdn url generator not test exclusive
adehad 4ada560
add new `include_plotlyjs='cdn'`behaviour to changelog
adehad 023ee57
fix tests after poor refactor
adehad 12db5cb
format after using right black version
adehad 7e4b256
format changelog entry better
adehad b4ecea0
Merge branch 'master' into lock_cdn_ver
nicolaskruchten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import sys | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
|
||
import plotly.graph_objs as go | ||
import plotly.io as pio | ||
from plotly.io._utils import plotly_cdn_url | ||
|
||
|
||
if sys.version_info >= (3, 3): | ||
import unittest.mock as mock | ||
from unittest.mock import MagicMock | ||
else: | ||
import mock | ||
from mock import MagicMock | ||
|
||
# fixtures | ||
# -------- | ||
@pytest.fixture | ||
def fig1(request): | ||
return go.Figure( | ||
data=[ | ||
{ | ||
"type": "scatter", | ||
"y": np.array([2, 1, 3, 2, 4, 2]), | ||
"marker": {"color": "green"}, | ||
} | ||
], | ||
layout={"title": {"text": "Figure title"}}, | ||
) | ||
|
||
|
||
# HTML | ||
# ---- | ||
def assert_latest_cdn_connected(html): | ||
assert plotly_cdn_url(cdn_ver="latest") in html | ||
|
||
|
||
def assert_locked_version_cdn_connected(html): | ||
assert plotly_cdn_url() in html | ||
|
||
|
||
def test_latest_cdn_included(fig1): | ||
html_str = pio.to_html(fig1, include_plotlyjs="cdn-latest") | ||
assert_latest_cdn_connected(html_str) | ||
|
||
|
||
def test_versioned_cdn_included(fig1): | ||
html_str = pio.to_html(fig1, include_plotlyjs="cdn") | ||
assert_locked_version_cdn_connected(html_str) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, if this is merged after #3030 - i.e. use j2 v2, this call should be changed to:
See: plotly/plotly.js#5462