Beispiel #1
0
 def test_get_figure_invalid_3(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/2/"
     py.sign_in(un, ak)
     with self.assertRaises(ValueError):
         py.get_figure(url)
Beispiel #2
0
    def setUp(self):
        py.sign_in('PlotlyImageTest',
                   '786r5mecv0',
                   plotly_domain='https://plot.ly',
                   plotly_api_domain='https://api.plot.ly')

        self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
Beispiel #3
0
 def test_get_figure_does_not_exist(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/1000000000/"
     py.sign_in(un, ak)
     with self.assertRaises(exceptions.PlotlyError):
         py.get_figure(url)
def test_get_figure_with_url():
    un = 'PlotlyImageTest'
    ak = '786r5mecv0'
    url = "https://plot.ly/~PlotlyImageTest/2/"
    py.sign_in(un, ak)
    print("getting: https://plot.ly/~PlotlyImageTest/2/")
    print("###########################################\n\n")
    fig = py.get_figure(url)
Beispiel #5
0
def test_get_figure_invalid_2():
    un = 'PlotlyImageTest'
    ak = '786r5mecv0'
    url = "https://plot.ly/~PlotlyImageTest/-1/"
    py.sign_in(un, ak)
    print("not getting: https://plot.ly/~PlotlyImageTest/-1/")
    print("###########################################\n\n")
    fig = py.get_figure(url)
def test_get_figure_does_not_exist():
    un = 'PlotlyImageTest'
    ak = '786r5mecv0'
    url = "https://plot.ly/~PlotlyImageTest/1000000000/"
    py.sign_in(un, ak)
    print("not getting: https://plot.ly/~PlotlyImageTest/1000000000/")
    print("###########################################\n\n")
    fig = py.get_figure(url)
def test_get_figure():
    un = 'PlotlyImageTest'
    ak = '786r5mecv0'
    file_id = 2
    py.sign_in(un, ak)
    print("getting: https://plot.ly/~{0}/{1}/".format(un, file_id))
    print("###########################################\n\n")
    fig = py.get_figure('PlotlyImageTest', str(file_id))
Beispiel #8
0
def test_get_figure_does_not_exist():
    un = 'plotlyimagetest'
    ak = '786r5mecv0'
    url = "https://plot.ly/~PlotlyImageTest/1000000000/"
    py.sign_in(un, ak)
    print("not getting: https://plot.ly/~PlotlyImageTest/1000000000/")
    print("###########################################\n\n")
    fig = py.get_figure(url)
Beispiel #9
0
def test_get_figure():
    un = 'plotlyimagetest'
    ak = '786r5mecv0'
    file_id = 2
    py.sign_in(un, ak)
    print("getting: https://plot.ly/~{0}/{1}/".format(un, file_id))
    print("###########################################\n\n")
    fig = py.get_figure('plotlyimagetest', str(file_id))
Beispiel #10
0
def test_get_figure_with_url():
    un = 'plotlyimagetest'
    ak = '786r5mecv0'
    url = "https://plot.ly/~PlotlyImageTest/2/"
    py.sign_in(un, ak)
    print("getting: https://plot.ly/~PlotlyImageTest/2/")
    print("###########################################\n\n")
    fig = py.get_figure(url)
Beispiel #11
0
 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)
 def test_sign_in(self):
     un = 'anyone'
     ak = 'something'
     # TODO, add this!
     # si = ['this', 'and-this']
     py.sign_in(un, ak)
     creds = py.get_credentials()
     self.assertEqual(creds['username'], un)
     self.assertEqual(creds['api_key'], ak)
 def test_sign_in(self):
     un = 'anyone'
     ak = 'something'
     # TODO, add this!
     # si = ['this', 'and-this']
     py.sign_in(un, ak)
     creds = py.get_credentials()
     self.assertEqual(creds['username'], un)
     self.assertEqual(creds['api_key'], ak)
def test_sign_in():
    un = 'anyone'
    ak = 'something'
    # TODO, add this!
    # si = ['this', 'and-this']
    py.sign_in(un, ak)
    creds = py.get_credentials()
    assert creds['username'] == un
    assert creds['api_key'] == ak
Beispiel #15
0
def test_sign_in():
    un = 'anyone'
    ak = 'something'
    # TODO, add this!
    # si = ['this', 'and-this']
    py.sign_in(un, ak)
    creds = py.get_credentials()
    assert creds['username'] == un
    assert creds['api_key'] == ak
Beispiel #16
0
def test_plot_valid():
    py.sign_in('PlotlyImageTest', '786r5mecv0')
    fig = {
        'data':[
            {
                'x':[1,2,3],
                'y':[2,1,2]
            }
        ]
    }
    url = py.plot(fig, auto_open=False, filename='plot_valid')
Beispiel #17
0
def test_plot_valid():
    py.sign_in('PlotlyImageTest', '786r5mecv0')
    fig = {
        'data':[
            {
                'x':[1,2,3],
                'y':[2,1,2]
            }
        ]
    }
    url = py.plot(fig, auto_open=False, filename='plot_valid')
Beispiel #18
0
 def test_sign_in_with_config(self):
     username = '******'
     api_key = 'place holder'
     plotly_domain = 'test domain'
     plotly_streaming_domain = 'test streaming domain'
     py.sign_in(
         username,
         api_key,
         plotly_domain=plotly_domain,
         plotly_streaming_domain=plotly_streaming_domain
     )
     config = py.get_config()
     self.assertEqual(config['plotly_domain'], plotly_domain)
     self.assertEqual(
         config['plotly_streaming_domain'], plotly_streaming_domain
     )
 def test_sign_in_with_config(self):
     username = '******'
     api_key = 'place holder'
     plotly_domain = 'test domain'
     plotly_streaming_domain = 'test streaming domain'
     plotly_ssl_verification = False
     py.sign_in(username,
                api_key,
                plotly_domain=plotly_domain,
                plotly_streaming_domain=plotly_streaming_domain,
                plotly_ssl_verification=plotly_ssl_verification)
     config = py.get_config()
     self.assertEqual(config['plotly_domain'], plotly_domain)
     self.assertEqual(config['plotly_streaming_domain'],
                      plotly_streaming_domain)
     self.assertEqual(config['plotly_ssl_verification'],
                      plotly_ssl_verification)
def test_all():
    un = 'PlotlyImageTest'
    ak = '786r5mecv0'
    run_test = False
    end_file = 2
    polar_plots = [],  # [6, 7, 8]
    skip = list(range(0))
    if run_test:
        py.sign_in(un, ak)
        file_id = 0
        while True:
            fig, fig_raw = None, None
            while (file_id in polar_plots) or (file_id in skip):
                print("    skipping: https://plot.ly/~{0}/{1}".format(
                    un, file_id))
                file_id += 1
            print("\n")
            try:
                print("testing: https://plot.ly/~{0}/{1}".format(un, file_id))
                print("###########################################\n\n")
                fig = py.get_figure('PlotlyImageTest', str(file_id))
                fig_raw = py.get_figure('PlotlyImageTest',
                                        str(file_id),
                                        raw=True)
            except exceptions.PlotlyError:
                pass
            if (fig is None) and (fig_raw is None):
                print("    couldn't find: https://plot.ly/{0}/{1}".format(
                    un, file_id))
            else:
                compare_with_raw(fig, fig_raw, parents=['figure'])
            file_id += 1
            if file_id > end_file:
                break
        raise exceptions.PlotlyError("This error was generated so that the "
                                     "following output is produced...")
Beispiel #21
0
def test_all():
    un = 'plotlyimagetest'
    ak = '786r5mecv0'
    run_test = False
    end_file = 2
    polar_plots = [],  #[6, 7, 8]
    skip = list(range(0))
    if run_test:
        py.sign_in(un, ak)
        file_id = 0
        while True:
            fig, fig_raw = None, None
            while (file_id in polar_plots) or (file_id in skip):
                print("    skipping: https://plot.ly/~{0}/{1}".format(
                    un, file_id))
                file_id += 1
            print("\n")
            try:
                print("testing: https://plot.ly/~{0}/{1}".format(un, file_id))
                print("###########################################\n\n")
                fig = py.get_figure('plotlyimagetest', str(file_id))
                fig_raw = py.get_figure('plotlyimagetest',
                                        str(file_id),
                                        raw=True)
            except exceptions.PlotlyError:
                pass
            if (fig is None) and (fig_raw is None):
                print("    couldn't find: https://plot.ly/{0}/{1}".format(
                    un, file_id))
            else:
                compare_with_raw(fig, fig_raw, parents=['figure'])
            file_id += 1
            if file_id > end_file:
                break
        raise exceptions.PlotlyError("This error was generated so that the "
                                     "following output is produced...")
Beispiel #22
0
A module intended for use with Nose.

"""
from __future__ import absolute_import

import matplotlib

# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from nose.tools import raises

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

py.sign_in('test-runner', '9h29fe3l0x')


@raises(exceptions.PlotlyError)
def test_update_type_error():
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3])
    update = []
    py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)


@raises(exceptions.PlotlyError)
def test_update_validation_error():
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3])
    update = {'invalid': 'anything'}
    def setUp(self):
        py.sign_in('PlotlyImageTest', '786r5mecv0',
                   plotly_domain='https://plot.ly',
                   plotly_api_domain='https://api.plot.ly')

        self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
 def test_sign_in_cannot_validate(self):
     self.users_current_mock.side_effect = exceptions.PlotlyRequestError(
         'msg', 400, 'foobar')
     with self.assertRaisesRegexp(exceptions.PlotlyError, 'Sign in failed'):
         py.sign_in('foo', 'bar')
Beispiel #25
0
def setUp():
    py.sign_in('PlotlyImageTest', '786r5mecv0',
               plotly_domain='https://plot.ly')
Beispiel #26
0
 def test_get_figure(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 13183
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id))
Beispiel #27
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
Beispiel #28
0
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
 def test_sign_in_cannot_validate(self):
     self.users_current_mock.side_effect = exceptions.PlotlyRequestError(
         'msg', 400, 'foobar'
     )
     with self.assertRaisesRegexp(exceptions.PlotlyError, 'Sign in failed'):
         py.sign_in('foo', 'bar')
Beispiel #30
0
 def test_proper_escaping(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/13185/"
     py.sign_in(un, ak)
     py.get_figure(url)
Beispiel #31
0
"""
from __future__ import absolute_import

import matplotlib

# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from nose.plugins.attrib import attr
from nose.tools import raises

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

py.sign_in('test-runner', '9h29fe3l0x')

@raises(exceptions.PlotlyError)
def test_update_type_error():
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3])
    update = []
    py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)


@raises(exceptions.PlotlyError)
def test_update_validation_error():
    fig, ax = plt.subplots()
    ax.plot([1, 2, 3])
    update = {'invalid': 'anything'}
    py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False)
Beispiel #32
0
 def setUp(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0',
                plotly_domain='https://plot.ly')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
     super(TestPlot, self).setUp()
Beispiel #33
0
 def test_get_figure_with_url(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/13183/"
     py.sign_in(un, ak)
     py.get_figure(url)
Beispiel #34
0
 def test(self):
     py.sign_in('username', 'key', **plot_options)
     self.assertRaises(PlotlyError, py._plot_option_logic, {})
Beispiel #35
0
 def test_plot_empty_data(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                       filename='plot_invalid')
Beispiel #36
0
 def test(self):
     py.sign_in('username', 'key', **plot_options['parent'])
     options = py._plot_option_logic(plot_options['child'])
     for option, value in plot_options['expected_output'].items():
         self.assertEqual(options[option], value)
Beispiel #37
0
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
Beispiel #38
0
 def setUp(self):
     py.sign_in('PlotlyImageTest',
                '786r5mecv0',
                plotly_domain='https://plot.ly')
Beispiel #39
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
Beispiel #40
0
 def test_plot_empty_data(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                       filename='plot_invalid')
Beispiel #41
0
 def test_get_figure_raw(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 2
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id), raw=True)