Merge lp:~mandel/ubuntu-sso-client/fix-proxy-q into lp:ubuntu-sso-client

Proposed by Manuel de la Peña on 2012-10-04
Status: Merged
Approved by: dobey on 2012-10-04
Approved revision: 1005
Merged at revision: 1004
Proposed branch: lp:~mandel/ubuntu-sso-client/fix-proxy-q
Merge into: lp:ubuntu-sso-client
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:~mandel/ubuntu-sso-client/fix-proxy-q
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve on 2012-10-04
dobey (community) 2012-10-04 Approve on 2012-10-04
Review via email: mp+127995@code.launchpad.net

Commit message

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

Description of the change

- Do not just set the application network but also set it in the nam to be sure we work in all versions (LP:#1061528).

To post a comment you must log in.
dobey (dobey) :
review: Approve
Diego Sarmentero (diegosarmentero) wrote :
Download full text (8.5 KiB)

I'm getting this:

[FAIL]
Traceback (most recent call last):
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/qt/tests/test_reset_password.py", line 106, in test_show_hide_event
    QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)")), 1)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 271, in assertEqual
    % (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = 2
b = 1

ubuntu_sso.qt.tests.test_reset_password.ResetPasswordTestCase.test_show_hide_event
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1045, in _inlineCallbacks
    result = g.send(result)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/tests/test_webclient.py", line 570, in test_anonymous_proxy_is_used
    self.wc.force_use_proxy(settings)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/qtnetwork.py", line 257, in force_use_proxy
    self._set_proxy(proxy)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/qtnetwork.py", line 111, in _set_proxy
    self.nam.setProxy(proxy)
exceptions.TypeError: QNetworkAccessManager.setProxy(QNetworkProxy): first argument of unbound method must have type 'QNetworkAccessManager'

ubuntu_sso.utils.webclient.tests.test_webclient.BasicProxyTestCase.test_anonymous_proxy_is_used
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1045, in _inlineCallbacks
    result = g.send(result)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/tests/test_webclient.py", line 618, in test_auth_proxy_is_requested_creds_bad_details
    self.wc.force_use_proxy(wrong_settings)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/qtnetwork.py", line 257, in force_use_proxy
    self._set_proxy(proxy)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/qtnetwork.py", line 111, in _set_proxy
    self.nam.setProxy(proxy)
exceptions.TypeError: QNetworkAccessManager.setProxy(QNetworkProxy): first argument of unbound method must have type 'QNetworkAccessManager'

ubuntu_sso.utils.webclient.tests.test_webclient.BasicProxyTestCase.test_auth_proxy_is_requested_creds_bad_details
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1045, in _inlineCallbacks
    result = g.send(result)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/tests/test_webclient.py", line 666, in test_auth_proxy_is_requested_creds_bad_details_everywhere
    self.wc.force_use_proxy(wrong_settings)
  File "/media/gatox/gato/proyectos/canonical/fix-proxy-q/ubuntu_sso/utils/webclient/qtnetwork.py", line 257, in force_use_proxy
    self._set_proxy(proxy)
  File "/...

Read more...

review: Needs Fixing
Diego Sarmentero (diegosarmentero) wrote :

+1
This is causing some weird issue running the whole suit in my machine, but working if running webclient tests individually

review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (116.9 KiB)

The attempt to merge lp:~mandel/ubuntu-sso-client/fix-proxy-q into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

*** Running QT test suite for ubuntu_sso ***
running build
Compiled data/qt/proxy_credentials_dialog.ui into ubuntu_sso/qt/ui/proxy_credentials_dialog_ui.py
compiled data/qt/resources.qrc into ubuntu_sso/qt/ui/resources_rc.py
Compiled data/qt/setup_account.ui into ubuntu_sso/qt/ui/setup_account_ui.py
Compiled data/qt/reset_password.ui into ubuntu_sso/qt/ui/reset_password_ui.py
Compiled data/qt/network_detection.ui into ubuntu_sso/qt/ui/network_detection_ui.py
Compiled data/qt/forgotten_password.ui into ubuntu_sso/qt/ui/forgotten_password_ui.py
Compiled data/qt/ssl_dialog.ui into ubuntu_sso/qt/ui/ssl_dialog_ui.py
Compiled data/qt/success_message.ui into ubuntu_sso/qt/ui/success_message_ui.py
Compiled data/qt/loadingoverlay.ui into ubuntu_sso/qt/ui/loadingoverlay_ui.py
Compiled data/qt/current_user_sign_in.ui into ubuntu_sso/qt/ui/current_user_sign_in_ui.py
Compiled data/qt/error_message.ui into ubuntu_sso/qt/ui/error_message_ui.py
Compiled data/qt/email_verification.ui into ubuntu_sso/qt/ui/email_verification_ui.py
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/account.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/credentials.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
copying ubuntu_sso/logger.py -> build/lib.linux-x86_64-2.7/ubuntu_sso
creating build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/test_credentials.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
copying ubuntu_sso/tests/test_account.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/tests
creating build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
copying ubuntu_sso/keyring/pykeyring.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring
creating build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_common.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
copying ubuntu_sso/keyring/tests/test_pykeyring.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/keyring/tests
creating build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/__init__.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/glib.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/linux.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/darwin.py -> build/lib.linux-x86_64-2.7/ubuntu_sso/main
copying ubuntu_sso/main/windows.py -> build/lib.linux-x86_64-2.7/ubun...

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 12:34:40 +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 12:34:40 +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