Merge lp:~dobey/ubuntu-sso-client/update-4-0 into lp:ubuntu-sso-client/stable-4-0

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 974
Merged at revision: 974
Proposed branch: lp:~dobey/ubuntu-sso-client/update-4-0
Merge into: lp:ubuntu-sso-client/stable-4-0
Diff against target: 70 lines (+13/-3)
2 files modified
ubuntu_sso/utils/webclient/qtnetwork.py (+9/-3)
ubuntu_sso/utils/webclient/tests/test_qtnetwork.py (+4/-0)
To merge this branch: bzr merge lp:~dobey/ubuntu-sso-client/update-4-0
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+128080@code.launchpad.net

Commit message

[Manuel de la Pena]

    - Set both application and nam proxy to work in all supported Qt versions. (LP: #1061528)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
Mike McCracken (mikemc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/webclient/qtnetwork.py'
2--- ubuntu_sso/utils/webclient/qtnetwork.py 2012-08-16 19:37:45 +0000
3+++ ubuntu_sso/utils/webclient/qtnetwork.py 2012-10-04 17:52:38 +0000
4@@ -104,6 +104,12 @@
5 self.proxy_retry = False
6 self.setup_proxy()
7
8+ def _set_proxy(self, proxy):
9+ """Set the proxy to be used."""
10+ QNetworkProxy.setApplicationProxy(proxy)
11+ # ensure that we work with the latest qt in ubuntu q
12+ self.nam.setProxy(proxy)
13+
14 def setup_proxy(self):
15 """Setup the proxy settings if needed."""
16 # QtNetwork knows how to use the system settings on both Win and Mac
17@@ -112,7 +118,7 @@
18 enabled = len(settings) > 0
19 if enabled and WebClient.proxy_instance is None:
20 proxy = build_proxy(settings)
21- QNetworkProxy.setApplicationProxy(proxy)
22+ self._set_proxy(proxy)
23 WebClient.proxy_instance = proxy
24 elif enabled and WebClient.proxy_instance:
25 logger.info("Proxy already in use.")
26@@ -123,7 +129,7 @@
27 logger.info("Querying OS for proxy.")
28 query = QNetworkProxyQuery(QUrl(PROXY_REQUEST))
29 proxies = QNetworkProxyFactory.systemProxyForQuery(query)
30- QNetworkProxy.setApplicationProxy(proxies[0])
31+ self._set_proxy(proxies[0])
32 WebClient.proxy_instance = proxies[0]
33
34 def handle_proxy_auth(self, proxy, authenticator):
35@@ -248,7 +254,7 @@
36 """Setup this webclient to use the given proxy settings."""
37 settings = {"https": https_settings}
38 proxy = build_proxy(settings)
39- QNetworkProxy.setApplicationProxy(proxy)
40+ self._set_proxy(proxy)
41 WebClient.proxy_instance = proxy
42
43 def shutdown(self):
44
45=== modified file 'ubuntu_sso/utils/webclient/tests/test_qtnetwork.py'
46--- ubuntu_sso/utils/webclient/tests/test_qtnetwork.py 2012-08-16 19:37:45 +0000
47+++ ubuntu_sso/utils/webclient/tests/test_qtnetwork.py 2012-10-04 17:52:38 +0000
48@@ -102,6 +102,8 @@
49
50 self.patch(qtnetwork, 'build_proxy', fake_build_proxy)
51 qtnetwork.WebClient.proxy_instance = None
52+ self.patch(qtnetwork.QNetworkAccessManager, 'setProxy',
53+ lambda _, p: self.called.append(('setProxy', p)))
54 self.addCleanup(self._clean_webclient_instance)
55
56 def _set_old_platform(self, platform):
57@@ -129,6 +131,7 @@
58 qtnetwork.WebClient()
59 self.assertEqual(self.proxy, qtnetwork.WebClient.proxy_instance)
60 self.assertIn(('setApplicationProxy', self.proxy), self.called)
61+ self.assertIn(('setProxy', self.proxy), self.called)
62 self.assertIn(('build_proxy', self.settings), self.called)
63
64 def test_setup_instance_present(self):
65@@ -138,6 +141,7 @@
66 qtnetwork.WebClient()
67 self.assertNotEqual(self.proxy, qtnetwork.WebClient.proxy_instance)
68 self.assertNotIn(('setApplicationProxy', self.proxy), self.called)
69+ self.assertNotIn(('setProxy', self.proxy), self.called)
70 self.assertNotIn(('build_proxy', self.settings), self.called)
71
72

Subscribers

People subscribed via source and target branches

to all changes: