コード例 #1
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 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)
コード例 #2
0
ファイル: test_image.py プロジェクト: xhesc/plotly.py
    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]}]
コード例 #3
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 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)
コード例 #4
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)
コード例 #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)
コード例 #6
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)
コード例 #7
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))
コード例 #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)
コード例 #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))
コード例 #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)
コード例 #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)
コード例 #12
0
 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)
コード例 #13
0
 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)
コード例 #14
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
コード例 #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
コード例 #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')
コード例 #17
0
ファイル: test_plot.py プロジェクト: abhiii5459/python-api
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')
コード例 #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
     )
コード例 #19
0
 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)
コード例 #20
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...")
コード例 #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...")
コード例 #22
0
ファイル: test_plot_mpl.py プロジェクト: sachinpc/python-api
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'}
コード例 #23
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]}]
コード例 #24
0
 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')
コード例 #25
0
ファイル: test_plot.py プロジェクト: yabloki/python-api
def setUp():
    py.sign_in('PlotlyImageTest', '786r5mecv0',
               plotly_domain='https://plot.ly')
コード例 #26
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 def test_get_figure(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     file_id = 13183
     py.sign_in(un, ak)
     py.get_figure('PlotlyImageTest', str(file_id))
コード例 #27
0
ファイル: test_image.py プロジェクト: codybushnell/plotly.py
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
コード例 #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]}]}
コード例 #29
0
 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')
コード例 #30
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 def test_proper_escaping(self):
     un = 'PlotlyImageTest'
     ak = '786r5mecv0'
     url = "https://plot.ly/~PlotlyImageTest/13185/"
     py.sign_in(un, ak)
     py.get_figure(url)
コード例 #31
0
ファイル: test_plot_mpl.py プロジェクト: yabloki/python-api
"""
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)
コード例 #32
0
ファイル: test_plot.py プロジェクト: zhy0313/plotly.py
 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()
コード例 #33
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 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)
コード例 #34
0
ファイル: test_plot.py プロジェクト: zhy0313/plotly.py
 def test(self):
     py.sign_in('username', 'key', **plot_options)
     self.assertRaises(PlotlyError, py._plot_option_logic, {})
コード例 #35
0
 def test_plot_empty_data(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                       filename='plot_invalid')
コード例 #36
0
ファイル: test_plot.py プロジェクト: zhy0313/plotly.py
 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)
コード例 #37
0
ファイル: test_plot.py プロジェクト: mode/plotly.py
 def setUp(self):
     super(TestPlot, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
コード例 #38
0
 def setUp(self):
     py.sign_in('PlotlyImageTest',
                '786r5mecv0',
                plotly_domain='https://plot.ly')
コード例 #39
0
 def setUp(self):
     super(TestImage, self).setUp()
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}]
コード例 #40
0
ファイル: test_plot.py プロジェクト: yabloki/python-api
 def test_plot_empty_data(self):
     py.sign_in('PlotlyImageTest', '786r5mecv0')
     self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                       filename='plot_invalid')
コード例 #41
0
ファイル: test_get_figure.py プロジェクト: adityag3/Plottest
 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)