示例#1
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(False)

        out = sys.stdout.getvalue()
        self.assertTrue("Local URL: http://localhost" in out)
        self.assertTrue("Network URL: http://internal-ip" in out)
示例#2
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)
示例#3
0
    def test_print_urls_base(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 = "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:8501/foo" in out)
        self.assertTrue("Network URL: http://internal-ip:8501/foo" in out)