Skip to content

Commit a320248

Browse files
committed
Use api.v2.plot_schema to get GRAPH_REFERENCE.
There is a circular import issue that needed to be fixed here as well.
1 parent 403034e commit a320248

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Diff for: plotly/tests/test_core/test_graph_reference/test_graph_reference.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,22 @@
99
from pkg_resources import resource_string
1010
from unittest import TestCase
1111

12-
import requests
13-
import six
1412
from nose.plugins.attrib import attr
1513

16-
from plotly import files, graph_reference as gr
14+
from plotly import graph_reference as gr
15+
from plotly.api import v2
1716
from plotly.graph_reference import string_to_class_name, get_role
1817
from plotly.tests.utils import PlotlyTestCase
1918

19+
FAKE_API_DOMAIN = 'https://api.am.not.here.ly'
20+
2021

2122
class TestGraphReferenceCaching(PlotlyTestCase):
2223

2324
@attr('slow')
2425
def test_default_schema_is_up_to_date(self):
25-
api_domain = files.FILE_CONTENT[files.CONFIG_FILE]['plotly_api_domain']
26-
graph_reference_url = '{}{}?sha1'.format(api_domain, '/v2/plot-schema')
27-
response = requests.get(graph_reference_url)
28-
if six.PY3:
29-
content = str(response.content, encoding='utf-8')
30-
else:
31-
content = response.content
32-
schema = json.loads(content)['schema']
26+
response = v2.plot_schema.retrieve('')
27+
schema = response.json()['schema']
3328

3429
path = os.path.join('package_data', 'default-schema.json')
3530
s = resource_string('plotly', path).decode('utf-8')

Diff for: plotly/tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from plotly import colors
2020
from plotly import utils
2121
from plotly import exceptions
22-
from plotly import graph_reference
2322
from plotly import session
2423
from plotly.files import (CONFIG_FILE, CREDENTIALS_FILE, FILE_CONTENT,
2524
check_file_permissions)
@@ -1357,6 +1356,7 @@ def validate(obj, obj_type):
13571356
13581357
"""
13591358
# TODO: Deprecate or move. #283
1359+
from plotly import graph_reference
13601360
from plotly.graph_objs import graph_objs
13611361

13621362
if obj_type not in graph_reference.CLASSES:

0 commit comments

Comments
 (0)