~dobey/ubuntuone-client/fix-test-fails

« back to all changes in this revision

Viewing changes to tests/proxy/test_tunnel_server.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2012-03-30 15:59:38 UTC
  • mfrom: (1217.1.2 fix-broken-tunnel)
  • Revision ID: tarmac-20120330155938-qt2fa0q7cb25eqnd
- Do not use the Qt Dbus mainloop on Windows (LP: #969150).
- Force using the system proxy on Windows (LP: #969157).

Show diffs side-by-side

added added

removed removed

Lines of Context:
549
549
class FakeNetworkProxyFactoryClass(object):
550
550
    """A fake QNetworkProxyFactory."""
551
551
    last_query = None
 
552
    use_system = False
552
553
 
553
554
    def __init__(self, enabled):
554
555
        """Initialize this fake instance."""
561
562
        """Return the proxy type configured."""
562
563
        return self.proxy_type
563
564
 
 
565
    @classmethod
 
566
    def setUseSystemConfiguration(cls, new_value):
 
567
        """Save the system configuration requested."""
 
568
        cls.use_system = new_value
 
569
 
 
570
    @classmethod
 
571
    def useSystemConfiguration(cls):
 
572
        """Is the system configured for proxies?"""
 
573
        return cls.use_system
 
574
 
564
575
    def systemProxyForQuery(self, query):
565
576
        """A list of proxies, but only type() will be called on the first."""
566
577
        return [self]
610
621
        self.patch(tunnel_server, "QNetworkProxyFactory", fake_netproxfact)
611
622
        self._assert_proxy_enabled("windows 1.0")
612
623
        self.assertEqual(len(self.app_proxy), 0)
 
624
        self.assertTrue(fake_netproxfact.useSystemConfiguration())
613
625
 
614
626
    def test_platform_other_disabled(self):
615
627
        """Tests for any other platform with proxies disabled."""
617
629
        self.patch(tunnel_server, "QNetworkProxyFactory", fake_netproxfact)
618
630
        self._assert_proxy_disabled("windows 1.0")
619
631
        self.assertEqual(len(self.app_proxy), 0)
 
632
        self.assertTrue(fake_netproxfact.useSystemConfiguration())
620
633
 
621
634
 
622
635
class FakeQCoreApp(object):
683
696
        tunnel_server.main(["example.com", "443"])
684
697
        self.assertIn("Proxy not enabled.", self.fake_stdout.getvalue())
685
698
        self.assertEqual(FakeQCoreApp.fake_instance, None)
 
699
 
 
700
    def test_qtdbus_installed_on_linux(self):
 
701
        """The QtDbus mainloop is installed."""
 
702
        self.patch(tunnel_server.sys, "platform", "linux123")
 
703
        installed = []
 
704
        self.patch(tunnel_server, "install_qt_dbus",
 
705
                  lambda: installed.append(None))
 
706
        self.proxies_enabled = True
 
707
        tunnel_server.main(["example.com", "443"])
 
708
        self.assertEqual(len(installed), 1)
 
709
 
 
710
    def test_qtdbus_not_installed_on_windows(self):
 
711
        """The QtDbus mainloop is installed."""
 
712
        self.patch(tunnel_server.sys, "platform", "win98")
 
713
        installed = []
 
714
        self.patch(tunnel_server, "install_qt_dbus",
 
715
                  lambda: installed.append(None))
 
716
        self.proxies_enabled = True
 
717
        tunnel_server.main(["example.com", "443"])
 
718
        self.assertEqual(len(installed), 0)