示例#1
0
    def test_print_urls_base_no_internal(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,
            "server.baseUrlPath":
            "foo",
            "server.port":
            8501,
            "global.useNode":
            False,
        })

        mock_get_internal_ip.return_value = None

        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:8501/foo" in out)
        self.assertTrue("Network URL: http://internal-ip:8501/foo" not in out)
示例#2
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()

        out = sys.stdout.getvalue()
        self.assertTrue('URL: http://the-address' in out)
示例#3
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()

        out = sys.stdout.getvalue()
        self.assertTrue("URL: http://the-address" in out)
示例#4
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)
示例#5
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)
示例#6
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)