-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 #2961 from adehad/lock_cdn_ver
Specify version of plotly.js in CDN URL
- Loading branch information
Showing
7 changed files
with
105 additions
and
21 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
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