Merge lp:~alecu/ubuntuone-client/proxy-tunnel-process into lp:ubuntuone-client
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | dobey on 2012-03-09 | ||||
| Approved revision: | 1219 | ||||
| Merged at revision: | 1204 | ||||
| Proposed branch: | lp:~alecu/ubuntuone-client/proxy-tunnel-process | ||||
| Merge into: | lp:ubuntuone-client | ||||
| Prerequisite: | lp:~alecu/ubuntuone-client/proxy-tunnel-client | ||||
| Diff against target: |
266 lines (+188/-1) 4 files modified
Makefile.am (+1/-0) bin/ubuntuone-proxy-tunnel (+24/-0) tests/proxy/test_tunnel_server.py (+132/-1) ubuntuone/proxy/tunnel_server.py (+31/-0) |
||||
| To merge this branch: | bzr merge lp:~alecu/ubuntuone-client/proxy-tunnel-process | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Alejandro J. Cura (community) | Abstain on 2012-03-09 | ||
| Eric Casteleijn (community) | Approve on 2012-03-09 | ||
| Manuel de la Peña (community) | 2012-03-06 | Approve on 2012-03-09 | |
|
Review via email:
|
|||
Commit Message
- A proxy tunnel process to be started when proxies are enabled (LP: #929207).
Description of the Change
- A proxy tunnel process to be started when proxies are enabled. (LP: #929207)
| Alejandro J. Cura (alecu) wrote : | # |
> A very stupid comments but why doing:
>
> if len(proxies) and proxies[0].type() != QNetworkProxy.
> return True
>
> When you an do:
>
> return len(proxies) and proxies[0].type() != QNetworkProxy.
>
> same for:
>
> if settings:
> return True
>
> In IsProxyEnabledT
>
> def _assert_
> """Assert that the proxy is enabled."""
> self.patch(
> ret = tunnel_
> str(SAMPLE_PORT))
> self.assertTrue
>
> def test_platform_
> """Tests for the linux platform with proxies enabled."""
> self.patch(
> lambda: FAKE_SETTINGS)
> self._assert_
>
> def test_platform_
> """Tests for any other platform with proxies enabled."""
> fake_netproxfact = FakeNetworkProx
> self.patch(
> fake_netproxfact)
> self._assert_
>
> Same for the disabled one.
Refactored all those tests as suggested.
> I think it would be a good idea to use sys.exit in main specially in the case
> were there is no proxy.
It's a normal condition for this process to exit if there's no proxy configured, so I think that it would be redundant to use sys.exit in this case.
Thanks for the review.
| Eric Casteleijn (thisfred) wrote : | # |
Looks great, two small observations that don't need any changes on this branch:
1. if we pass too many arguments to tunnel_server.py, we'll get strange errors, but since it doesn't look like anything users will ever call themselves, it's probably fine.
2. The new Python 3 style formatting is nice, but it means we need 2.7+ for this to work (which may already be a requirement,) but also, it's reportedly *way* less efficient than the old string formatting syntax, and there are no plans to ever remove that from the language, which makes me think we should probably just stick with the old one.
| Alejandro J. Cura (alecu) wrote : | # |
> 2. The new Python 3 style formatting is nice, but it means we need 2.7+ for
> this to work (which may already be a requirement,) but also, it's reportedly
> *way* less efficient than the old string formatting syntax, and there are no
> plans to ever remove that from the language, which makes me think we should
> probably just stick with the old one.
This is a very good point.
Since str.format() is not being used anywhere else in u1-client I'll change this in the following branch to use the % formatting operator.
Thanks for the review!
| Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0, Pending == 0. Got: 2 Approve, 1 Pending.


A very stupid comments but why doing:
if len(proxies) and proxies[0].type() != QNetworkProxy. NoProxy:
return True
When you an do:
return len(proxies) and proxies[0].type() != QNetworkProxy. NoProxy
same for:
if settings:
return True
In IsProxyEnabledT estCase I think you can merge the tests cases, for example:
def _assert_ enabled( self, platform):
"""Assert that the proxy is enabled."""
self. patch(tunnel_ server. sys, "platform", platform)
ret = tunnel_ server. is_proxy_ enabled( SAMPLE_ HOST, str(SAMPLE_PORT))
self. assertTrue( ret, "Proxy is enabled.")
def test_platform_ linux_enabled( self):
"""Tests for the linux platform with proxies enabled."""
self. patch(tunnel_ server. gsettings, "get_proxy_ settings" ,
lambda: FAKE_SETTINGS)
self. _assert_ enabled( 'linux3' )
def test_platform_ other_enabled( self):
"""Tests for any other platform with proxies enabled."""
fake_ netproxfact = FakeNetworkProx yFactoryClass( True)
self. patch(tunnel_ server, "QNetworkProxyF actory" , fake_netproxfact)
self. _assert_ enabled( 'windows 1.0')
Same for the disabled one.
I think it would be a good idea to use sys.exit in main specially in the case were there is no proxy.