<commit_before>"""
test_plot:
==========

A module intended for use with Nose.

"""
from __future__ import absolute_import

import requests
import six
import json

from unittest import TestCase
from nose.plugins.attrib import attr
from nose.tools import raises

from plotly.tests.utils import PlotlyTestCase
import plotly.tools as tls
from plotly.plotly import plotly as py
from plotly.exceptions import PlotlyError, PlotlyEmptyDataError
from plotly.files import CONFIG_FILE

# username for tests: 'PlotlyImageTest'
# api_key for account: '<KEY>'


@attr('slow')
def test_plot_valid():
    fig = {
        'data': [
            {
                'x': [1, 2, 3],
                'y': [2, 1, 2]
            }
        ]
    }
    py.plot(fig, auto_open=False, filename='plot_valid')


@raises(PlotlyError)
def test_plot_invalid():
    fig = {
        'data': [
            {
                'x': [1, 2, 3],
                'y': [2, 1, 2],
                'z': [3, 4, 1]
            }
        ]
    }
    py.plot(fig, auto_open=False, filename='plot_invalid')


@raises(TypeError)
def test_plot_invalid_args_1():
    py.plot(x=[1, 2, 3], y=[2, 1, 2], auto_open=False, filename='plot_invalid')


@raises(PlotlyError)
def test_plot_invalid_args_2():
    py.plot([1, 2, 3], [2, 1, 2], auto_open=False, filename='plot_invalid')


class TestPlot(TestCase):
    def setUp(self):
        py.sign_in('PlotlyImageTest', '<KEY>',
                   plotly_domain='https://plot.ly')
        self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]}
        super(TestPlot, self).setUp()

    def test_plot_empty_data(self):
        py.sign_in('PlotlyImageTest', '786r5mecv0')
        self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                          filename='plot_invalid')

    def test_plot_sharing_invalid_argument(self):

        # Raise an error if sharing argument is incorrect
        # correct arguments {'public, 'private', 'secret'}

        kwargs = {'filename': 'invalid-sharing-argument',
                  'sharing': 'privste'}

        with self.assertRaisesRegexp(
                PlotlyError,
                "The 'sharing' argument only accepts"):
            py.plot(self.simple_figure, **kwargs)
<commit_msg>signin with plotly test case<commit_after>"""
test_plot:
==========

A module intended for use with Nose.

"""
from __future__ import absolute_import

import requests
import six
import json

from unittest import TestCase
from nose.plugins.attrib import attr
from nose.tools import raises

from plotly.tests.utils import PlotlyTestCase
import plotly.tools as tls
from plotly.plotly import plotly as py
from plotly.exceptions import PlotlyError, PlotlyEmptyDataError
from plotly.files import CONFIG_FILE

# username for tests: 'PlotlyImageTest'
# api_key for account: '<KEY>'


class TestPlot(TestCase):
    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()

    @attr('slow')
    def test_plot_valid(self):
        fig = {
            'data': [
                {
                    'x': [1, 2, 3],
                    'y': [2, 1, 2]
                }
            ]
        }
        py.plot(fig, auto_open=False, filename='plot_valid')

    @raises(PlotlyError)
    def test_plot_invalid(self):
        fig = {
            'data': [
                {
                    'x': [1, 2, 3],
                    'y': [2, 1, 2],
                    'z': [3, 4, 1]
                }
            ]
        }
        py.plot(fig, auto_open=False, filename='plot_invalid')

    @raises(TypeError)
    def test_plot_invalid_args_1(self):
        py.plot(x=[1, 2, 3], y=[2, 1, 2], auto_open=False, filename='plot_invalid')

    @raises(PlotlyError)
    def test_plot_invalid_args_2(self):
        py.plot([1, 2, 3], [2, 1, 2], auto_open=False, filename='plot_invalid')

    def test_plot_empty_data(self):
        self.assertRaises(PlotlyEmptyDataError, py.plot, [],
                          filename='plot_invalid')

    def test_plot_sharing_invalid_argument(self):

        # Raise an error if sharing argument is incorrect
        # correct arguments {'public, 'private', 'secret'}

        kwargs = {'filename': 'invalid-sharing-argument',
                  'sharing': 'privste'}

        with self.assertRaisesRegexp(
                PlotlyError,
                "The 'sharing' argument only accepts"):
            py.plot(self.simple_figure, **kwargs)

{'fraction_non_alphanumeric': 0.13184406482698205, 'fraction_numerical': 0.017520805957074025, 'mean_word_length': 2.3384502923976607, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2759475', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1425, 'n_words': 354}