Skip to content

Revamp streaming #253

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
prettify tests and update imports
  • Loading branch information
theengineear committed Jul 7, 2015
commit fce9ba33d288cb67c03b55d9fad2c343161c4bcc
6 changes: 0 additions & 6 deletions plotly/tests/test_core/test_get_figure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
def setup_package():
pass


def teardown_package():
pass
45 changes: 20 additions & 25 deletions plotly/tests/test_core/test_get_figure/test_get_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
A module intended for use with Nose.

"""
from plotly.graph_objs import graph_objs
from plotly.plotly import plotly as py
from plotly import exceptions
from nose.tools import raises
import six
from __future__ import absolute_import

from unittest import TestCase
from unittest import TestCase, skipIf

version = six.sys.version_info[:2] # need this for conditional testing
from nose.tools import raises
import six

from plotly import exceptions
from plotly.graph_objs import graph_objs
from plotly.plotly import plotly as py

# username for tests: 'plotlyimagetest'
# api_key for account: '786r5mecv0'
Expand Down Expand Up @@ -53,8 +53,9 @@ def compare_with_raw(obj, raw_obj, parents=None):
for entry, entry_raw in zip(obj, raw_obj):
if isinstance(entry, (dict, list)):
try:
coll_name = graph_objs.NAME_TO_KEY[entry.__class__
.__name__]
coll_name = (
graph_objs.NAME_TO_KEY[entry.__class__.__name__]
)
except KeyError:
coll_name = entry.__class__.__name__
if parents is None:
Expand Down Expand Up @@ -163,7 +164,7 @@ def test_all():
ak = '786r5mecv0'
run_test = False
end_file = 2
polar_plots = [], #[6, 7, 8]
polar_plots = [], # [6, 7, 8]
skip = list(range(0))
if run_test:
py.sign_in(un, ak)
Expand Down Expand Up @@ -198,18 +199,12 @@ def test_all():

class TestBytesVStrings(TestCase):

# unittest `skipIf` not supported in 2.6
if version < (2, 7) or (2, 7) < version < (3, 3):
pass
else:
from unittest import skipIf

@skipIf(not six.PY3, 'Decoding and missing escapes only seen in PY3')
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
py.sign_in(un, ak)
print("getting: https://plot.ly/~PlotlyImageTest/91/")
print("###########################################\n\n")
fig = py.get_figure(url)
@skipIf(not six.PY3, 'Decoding and missing escapes only seen in PY3')
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
py.sign_in(un, ak)
print("getting: https://plot.ly/~PlotlyImageTest/91/")
print("###########################################\n\n")
fig = py.get_figure(url)
6 changes: 0 additions & 6 deletions plotly/tests/test_core/test_get_requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
def setup_package():
pass


def teardown_package():
pass
11 changes: 3 additions & 8 deletions plotly/tests/test_core/test_get_requests/test_get_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
A module intended for use with Nose.

"""

import requests
import copy
import json
import requests

import six
import sys

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json

default_headers = {'plotly-username': '',
'plotly-apikey': '',
Expand Down Expand Up @@ -151,4 +147,3 @@ def test_valid_request():
# if figure['data'][0]['x'] != [u'1', u'2', u'3']:
# print('ERROR')
# return res

8 changes: 3 additions & 5 deletions plotly/tests/test_core/test_graph_objs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
def setup_package():
import warnings
warnings.filterwarnings('ignore')
import warnings


def teardown_package():
pass
def setup_package():
warnings.filterwarnings('ignore')
4 changes: 3 additions & 1 deletion plotly/tests/test_core/test_graph_objs/nose_tools.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import absolute_import

from numbers import Number as Num

import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')

from plotly.matplotlylib import Exporter, PlotlyRenderer
from numbers import Number as Num


def compare_dict(dict1, dict2, equivalent=True, msg='', tol=10e-8):
Expand Down
14 changes: 6 additions & 8 deletions plotly/tests/test_core/test_graph_objs/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
from __future__ import absolute_import

from nose.tools import raises
from plotly.graph_objs import *
from plotly.exceptions import (PlotlyError,
PlotlyDictKeyError,
PlotlyDictValueError,
PlotlyDataTypeError,
PlotlyListEntryError)

from plotly.exceptions import (PlotlyError, PlotlyDictKeyError,
PlotlyDictValueError, PlotlyListEntryError)
from plotly.graph_objs import Annotation, Annotations, Data, Figure, Layout



def setup():
Expand Down Expand Up @@ -69,7 +68,7 @@ def test_validate():
annotations.validate()
annotations += [{'text': 'some text'}]
annotations.validate()
annotations += [{},{},{}]
annotations += [{}, {}, {}]
annotations.validate()


Expand All @@ -78,4 +77,3 @@ def test_validate_error():
annotations = Annotations()
annotations.append({'not-a-key': 'anything'})
annotations.validate()

61 changes: 24 additions & 37 deletions plotly/tests/test_core/test_graph_objs/test_append_trace.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import plotly
from plotly.graph_objs import *
import plotly.tools as tls
from __future__ import absolute_import

from nose.tools import raises

from plotly.graph_objs import (Data, Figure, Layout, Scatter, Scatter3d, Scene,
XAxis, YAxis)
import plotly.tools as tls


@raises(Exception)
def test_print_grid_before_make_subplots():
fig = Figure()
fig.print_grid()


@raises(Exception)
def test_append_trace_before_make_subplots():
trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = Figure()
fig.append_trace(trace, 2, 2)


@raises(Exception)
def test_append_trace_row_out_of_range():
trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = tls.make_subplots(rows=2, cols=3)
fig.append_trace(trace, 10, 2)


@raises(Exception)
def test_append_trace_col_out_of_range():
trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = tls.make_subplots(rows=2, cols=3)
fig.append_trace(trace, 2, 0)


def test_append_scatter():
expected = Figure(
data=Data([
Expand Down Expand Up @@ -96,34 +96,28 @@ def test_append_scatter():
)
)

trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = tls.make_subplots(rows=2, cols=3)
fig.append_trace(trace, 2, 2)
assert fig == expected


@raises(Exception)
def test_append_scatter_after_deleting_xaxis():
trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = tls.make_subplots(rows=2, cols=3)
fig['layout'].pop('xaxis5', None)
fig.append_trace(trace, 2, 2)


@raises(Exception)
def test_append_scatter_after_deleting_yaxis():
trace = Scatter(
x=[1,2,3],
y=[2,3,4]
)
trace = Scatter(x=[1, 2, 3], y=[2, 3, 4])
fig = tls.make_subplots(rows=2, cols=3)
fig['layout'].pop('yaxis5', None)
fig.append_trace(trace, 2, 2)


def test_append_scatter3d():
expected = Figure(
data=Data([
Expand Down Expand Up @@ -153,24 +147,17 @@ def test_append_scatter3d():
fig = tls.make_subplots(rows=2, cols=1,
specs=[[{'is_3d': True}],
[{'is_3d': True}]])
trace = Scatter3d(
x=[1,2,3],
y=[2,3,4],
z=[1,2,3]
)
trace = Scatter3d(x=[1, 2, 3], y=[2, 3, 4], z=[1, 2, 3])
fig.append_trace(trace, 1, 1)
fig.append_trace(trace, 2, 1)
assert fig == expected


@raises(Exception)
def test_append_scatter3d_after_deleting_scene():
fig = tls.make_subplots(rows=2, cols=1,
specs=[[{'is_3d': True}],
[{'is_3d': True}]])
trace = Scatter3d(
x=[1,2,3],
y=[2,3,4],
z=[1,2,3]
)
trace = Scatter3d(x=[1, 2, 3], y=[2, 3, 4], z=[1, 2, 3])
fig['layout'].pop('scene1', None)
fig.append_trace(trace, 1, 1)
2 changes: 2 additions & 0 deletions plotly/tests/test_core/test_graph_objs/test_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
are properly defined in both graph_objs.py and included in the mapping dicts.

"""
from __future__ import absolute_import

from plotly.graph_objs import graph_objs


Expand Down
12 changes: 5 additions & 7 deletions plotly/tests/test_core/test_graph_objs/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
from __future__ import absolute_import

from nose.tools import raises
from plotly.graph_objs import *
from plotly.exceptions import (PlotlyError,
PlotlyDictKeyError,
PlotlyDictValueError,
PlotlyDataTypeError,

from plotly.exceptions import (PlotlyError, PlotlyDictKeyError,
PlotlyDictValueError, PlotlyDataTypeError,
PlotlyListEntryError)
from plotly.graph_objs import Annotations, Data, Figure, Layout


def setup():
Expand Down Expand Up @@ -78,7 +77,7 @@ def test_validate():
data.validate()
data += [{'type': 'scatter'}]
data.validate()
data += [{},{},{}]
data += [{}, {}, {}]
data.validate()


Expand All @@ -87,4 +86,3 @@ def test_validate_error():
data = Data()
data.append({'not-a-key': 'anything'})
data.validate()

7 changes: 2 additions & 5 deletions plotly/tests/test_core/test_graph_objs/test_error_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
from __future__ import absolute_import

from nose.tools import raises
from plotly.graph_objs import *
from plotly.exceptions import (PlotlyDictKeyError,
PlotlyDictValueError,
PlotlyDataTypeError,
PlotlyListEntryError)
from plotly.graph_objs import ErrorX, ErrorY
from plotly.exceptions import PlotlyDictKeyError


def test_instantiate_error_x():
Expand Down
3 changes: 2 additions & 1 deletion plotly/tests/test_core/test_graph_objs/test_get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from unittest import TestCase

from plotly.graph_objs import *
from plotly.graph_objs import (Data, Figure, Layout, Line, Margin, Marker,
Scatter, XAxis, YAxis)


class TestGetData(TestCase):
Expand Down
Loading