Example #1
0
    def test_print_urls_configured(self):
        mock_is_manually_set = testutil.build_mock_config_is_manually_set(
            {"browser.serverAddress": True})
        mock_get_option = testutil.build_mock_config_get_option(
            {"browser.serverAddress": "the-address"})

        with patch.object(config, "get_option",
                          new=mock_get_option), patch.object(
                              config,
                              "is_manually_set",
                              new=mock_is_manually_set):
            bootstrap._print_url(False)

        out = sys.stdout.getvalue()
        self.assertTrue(
            "You can now view your Streamlit app in your browser." in out)
        self.assertTrue("URL: http://the-address" in out)
Example #2
0
    def test_print_hello_message(self):
        mock_is_manually_set = testutil.build_mock_config_is_manually_set(
            {"browser.serverAddress": True})
        mock_get_option = testutil.build_mock_config_get_option(
            {"browser.serverAddress": "the-address"})

        with patch.object(config, "get_option",
                          new=mock_get_option), patch.object(
                              config,
                              "is_manually_set",
                              new=mock_is_manually_set):
            bootstrap._print_url(True)

        out = sys.stdout.getvalue()
        self.assertTrue(
            "Welcome to Streamlit. Check out our demo in your browser." in out)
        self.assertTrue("URL: http://the-address" in out)
Example #3
0
    def test_print_urls_local(self, mock_get_internal_ip):
        mock_is_manually_set = testutil.build_mock_config_is_manually_set(
            {"browser.serverAddress": False})
        mock_get_option = testutil.build_mock_config_get_option(
            {"server.headless": False})

        mock_get_internal_ip.return_value = "internal-ip"

        with patch.object(config, "get_option",
                          new=mock_get_option), patch.object(
                              config,
                              "is_manually_set",
                              new=mock_is_manually_set):
            bootstrap._print_url()

        out = sys.stdout.getvalue()
        self.assertTrue("Local URL: http://localhost" in out)
        self.assertTrue("Network URL: http://internal-ip" in out)
Example #4
0
    def test_print_urls_remote(self, mock_get_internal_ip,
                               mock_get_external_ip):

        mock_is_manually_set = testutil.build_mock_config_is_manually_set(
            {'browser.serverAddress': False})
        mock_get_option = testutil.build_mock_config_get_option(
            {'server.headless': True})

        mock_get_internal_ip.return_value = 'internal-ip'
        mock_get_external_ip.return_value = 'external-ip'

        with patch.object(config, 'get_option', new=mock_get_option), \
            patch.object(
                config, 'is_manually_set', new=mock_is_manually_set):
            bootstrap._print_url()

        out = sys.stdout.getvalue()
        self.assertTrue('Network URL: http://internal-ip' in out)
        self.assertTrue('External URL: http://external-ip' in out)