Ejemplo n.º 1
0
    def test_set_config_file_all_entries(self):

        # Check set_config and get_config return the same values

        domain, streaming_domain, api, sharing = ('this', 'thing', 'that',
                                                  'private')
        ssl_verify, proxy_auth, world_readable, auto_open = (True, True, False,
                                                             False)
        tools.set_config_file(plotly_domain=domain,
                              plotly_streaming_domain=streaming_domain,
                              plotly_api_domain=api,
                              plotly_ssl_verification=ssl_verify,
                              plotly_proxy_authorization=proxy_auth,
                              world_readable=world_readable,
                              auto_open=auto_open)
        config = tools.get_config_file()
        self.assertEqual(config['plotly_domain'], domain)
        self.assertEqual(config['plotly_streaming_domain'], streaming_domain)
        self.assertEqual(config['plotly_api_domain'], api)
        self.assertEqual(config['plotly_ssl_verification'], ssl_verify)
        self.assertEqual(config['plotly_proxy_authorization'], proxy_auth)
        self.assertEqual(config['world_readable'], world_readable)
        self.assertEqual(config['sharing'], sharing)
        self.assertEqual(config['auto_open'], auto_open)
        tools.reset_config_file()
Ejemplo n.º 2
0
    def test_set_config_file_all_entries(self):

        # Check set_config and get_config return the same values

        domain, streaming_domain, api, sharing = ("this", "thing", "that", "private")
        ssl_verify, proxy_auth, world_readable, auto_open = (True, True, False, False)
        tools.set_config_file(
            plotly_domain=domain,
            plotly_streaming_domain=streaming_domain,
            plotly_api_domain=api,
            plotly_ssl_verification=ssl_verify,
            plotly_proxy_authorization=proxy_auth,
            world_readable=world_readable,
            auto_open=auto_open,
        )
        config = tools.get_config_file()
        self.assertEqual(config["plotly_domain"], domain)
        self.assertEqual(config["plotly_streaming_domain"], streaming_domain)
        self.assertEqual(config["plotly_api_domain"], api)
        self.assertEqual(config["plotly_ssl_verification"], ssl_verify)
        self.assertEqual(config["plotly_proxy_authorization"], proxy_auth)
        self.assertEqual(config["world_readable"], world_readable)
        self.assertEqual(config["sharing"], sharing)
        self.assertEqual(config["auto_open"], auto_open)
        tools.reset_config_file()
Ejemplo n.º 3
0
    def test_set_config_no_warning_msg_if_plotly_domain_is_https(self):

        # Check that no UserWarning is being called with https plotly_domain

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            kwargs = {'plotly_domain': 'https://www.foo-bar.com'}
            tools.set_config_file(**kwargs)
            assert len(w) == 0
Ejemplo n.º 4
0
    def test_set_config_expected_warning_msg(self):

        # Check that UserWarning is being called with http plotly_domain

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            kwargs = {'plotly_domain': 'http://www.foo-bar.com'}
            tools.set_config_file(**kwargs)
            assert len(w) == 1
            assert issubclass(w[-1].category, UserWarning)
            assert "plotly_domain" in str(w[-1].message)
Ejemplo n.º 5
0
 def test_set_config_updates_plot_options(self):
     original_config = tls.get_config_file()
     new_options = {
         'world_readable': not original_config['world_readable'],
         'auto_open': not original_config['auto_open'],
         'sharing': ('public' if original_config['world_readable'] is False
                     else 'secret')
     }
     tls.set_config_file(**new_options)
     options = py._plot_option_logic({})
     for key in new_options:
         self.assertEqual(new_options[key], options[key])
Ejemplo n.º 6
0
    def test_set_config_file_two_entries(self):

        # Check set_config and get_config given only two entries return the
        # same values

        domain, streaming_domain = 'this', 'thing'
        tools.set_config_file(plotly_domain=domain,
                              plotly_streaming_domain=streaming_domain)
        config = tools.get_config_file()
        self.assertEqual(config['plotly_domain'], domain)
        self.assertEqual(config['plotly_streaming_domain'], streaming_domain)
        tools.reset_config_file()
Ejemplo n.º 7
0
 def test_set_config_updates_plot_options(self):
     original_config = tls.get_config_file()
     new_options = {
         'world_readable': not original_config['world_readable'],
         'auto_open': not original_config['auto_open'],
         'sharing': ('public' if original_config['world_readable'] is False
                     else 'secret')
     }
     tls.set_config_file(**new_options)
     options = py._plot_option_logic({})
     for key in new_options:
         self.assertEqual(new_options[key], options[key])
Ejemplo n.º 8
0
 def test_set_config_updates_plot_options(self):
     original_config = tls.get_config_file()
     new_options = {
         "world_readable":
         not original_config["world_readable"],
         "auto_open":
         not original_config["auto_open"],
         "sharing": ("public" if original_config["world_readable"] is False
                     else "secret"),
     }
     tls.set_config_file(**new_options)
     options = py._plot_option_logic({})
     for key in new_options:
         self.assertEqual(new_options[key], options[key])
def plotly_setup():
    user = os.environ['plotly_user']
    key = os.environ['plotly_key']
    py.sign_in(username=user, api_key=key)
    set_config_file(plotly_domain="https://plotly.com",
                    plotly_api_domain="https://api.plotly.com")