def test_fix_turkish_locale_called(self):
     """The fix_turkish_locale function is called, always."""
     called = []
     self.patch(tunnel_server, "fix_turkish_locale",
                lambda *args, **kwargs: called.append((args, kwargs)))
     tunnel_server.main(["localhost", "443"])
     self.assertEqual(called, [((), {})])
 def test_qtdbus_not_installed_on_windows(self):
     """The QtDbus mainloop is installed."""
     self.patch(tunnel_server.sys, "platform", "win98")
     installed = []
     self.patch(
         tunnel_server, "install_qt_dbus", lambda: installed.append(None))
     self.proxies_enabled = True
     tunnel_server.main(["example.com", "443"])
     self.assertEqual(len(installed), 0)
    def test_on_proxies_enabled_prints_port_and_cookie(self):
        """With proxies enabled print port to stdout and start the mainloop."""
        self.patch(tunnel_server.uuid, "uuid4", lambda: FAKE_COOKIE)
        self.proxies_enabled = True
        port = 443
        tunnel_server.main(["example.com", str(port)])
        stdout = self.fake_stdout.getvalue()

        self.assertIn(tunnel_server.TUNNEL_PORT_LABEL + ": ", stdout)
        cookie_line = tunnel_server.TUNNEL_COOKIE_LABEL + ": " + FAKE_COOKIE
        self.assertIn(cookie_line, stdout)
 def test_on_proxies_disabled_exit(self):
     """With proxies disabled, print a message and exit gracefully."""
     self.proxies_enabled = False
     tunnel_server.main(["example.com", "443"])
     self.assertIn("Proxy not enabled.", self.fake_stdout.getvalue())
     self.assertEqual(FakeQCoreApp.fake_instance, None)
 def test_checks_proxies(self):
     """Main checks that the proxies are enabled."""
     tunnel_server.main([])
     self.assertEqual(len(self.called), 1)