Merge lp:~diegosarmentero/ubuntu-sso-client/network-detect into lp:ubuntu-sso-client
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Alejandro J. Cura on 2012-01-04 | ||||
| Approved revision: | 824 | ||||
| Merged at revision: | 827 | ||||
| Proposed branch: | lp:~diegosarmentero/ubuntu-sso-client/network-detect | ||||
| Merge into: | lp:ubuntu-sso-client | ||||
| Diff against target: |
407 lines (+253/-11) 7 files modified
ubuntu_sso/networkstate/__init__.py (+8/-0) ubuntu_sso/networkstate/linux.py (+24/-0) ubuntu_sso/networkstate/tests/test_linux.py (+137/-2) ubuntu_sso/networkstate/tests/test_windows.py (+64/-0) ubuntu_sso/networkstate/windows.py (+13/-5) ubuntu_sso/qt/controllers.py (+2/-2) ubuntu_sso/qt/tests/test_controllers.py (+5/-2) |
||||
| To merge this branch: | bzr merge lp:~diegosarmentero/ubuntu-sso-client/network-detect | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Alejandro J. Cura (community) | Approve on 2012-01-04 | ||
| Natalia Bidart | 2011-09-26 | Approve on 2011-11-07 | |
|
Review via email:
|
|||
Commit Message
- Fixed: Missing page: No network detected (LP: #804610).
Description of the Change
Fixed: Missing page: No network detected (LP: #804610).
- 796. By Diego Sarmentero on 2011-09-26
-
lint issues fixed.
- 797. By Diego Sarmentero on 2011-09-29
-
Improving networkstate to support is_machine_
connected for both: linux and windows.
| Natalia Bidart (nataliabidart) wrote : | # |
* Can you please change the docstring to be:
"""Return a deferred that when fired, will return True if the machine is online."""
* Do not add this check:
if not d.called:
if the deferred was already called, then we have a bug we need to solve.
* I think this is not correct:
result = (state != OFFLINE)
online will it be:
result = int(state) in NM_STATE_
* I think you need to refactor the test, or maybe you forgot a commit/push? The tests should patch NetworkManagerState and assert over the returned deferred.
| Natalia Bidart (nataliabidart) wrote : | # |
Also, the windows tets for is_already_
- 798. By Diego Sarmentero on 2011-10-03
-
Improved tests.
| Natalia Bidart (nataliabidart) wrote : | # |
I still get lint issues:
ubuntu_
126: [C0111, FakeWininet] Missing docstring
130: [C0103, FakeWininet.
- 799. By Diego Sarmentero on 2011-10-03
-
Fixed lint issues.
| Natalia Bidart (nataliabidart) wrote : | # |
This docstring is not pep-257 compliant:
"""Return a deferred that when fired, will return True if the
machine is online."""
must be something like:
"""Return a deferred that when fired, returns if the machine is online."""
* Why you patch dbus on ubuntu_
You need to patch the NetworkManagerState at setUp time, and change the fake implementation so you can customize the returned state. That way, you can safely ensure that your code is returning True when the result is in the NM_STATE_
So, summing up:
- Remove the 'fake_network_
- Build a fake NetworkManagerState that behaves more like the real one (ie make it so it can returns any code from the constant list)
- You should have a test per each constant, asserting either True or False accordingly.
* Since is_machine_
* In both implementation, the deferred you're returning should errback if there is any error. So you'd need to add try-except clauses to the calculation of the net state and errback the deferred on error.
- 800. By Diego Sarmentero on 2011-10-06
-
Improved use of Deferred.
- 801. By Diego Sarmentero on 2011-10-07
-
Improved Sign In Page flow, to use check_connection.
| Alejandro J. Cura (alecu) wrote : | # |
The branch looks mostly fine, but here are a few comments:
--
Instead of "Exception(
--
It's usually error prone to set class attributes (or any other global state) from tests, so instead of:
FakeNetworkM
please use something like:
self.
--
thanks!
- 802. By Diego Sarmentero on 2011-10-07
-
merge
- 803. By Diego Sarmentero on 2011-10-07
-
Improved Network state.
- 804. By Diego Sarmentero on 2011-10-11
-
merge
| Natalia Bidart (nataliabidart) wrote : | # |
Lots of lint issues! :-)
== Python Lint Notices ==
ubuntu_
30: [C0111, NetworkFailExce
ubuntu_
146: [W0702, is_machine_
ubuntu_
80: [C0103, TestConnection.
88: [C0103, TestConnection.
96: [C0103, TestConnection.
104: [C0103, TestConnection.
112: [C0103, TestConnection.
120: [C0103, TestConnection.
128: [C0103, TestConnection.
136: [C0103, TestConnection.
144: [C0103, TestConnection.
152: [C0103, TestConnection.
160: [C0103, TestConnection.
174: [W0703, TestConnection.
ubuntu_
184: [W0703, TestConnection.
ubuntu_
183: [W0702, is_machine_
- 805. By Diego Sarmentero on 2011-10-12
-
Fixed lint issues.
| Natalia Bidart (nataliabidart) wrote : | # |
Lint issues still appears:
== Python Lint Notices ==
ubuntu_
174: [W0703, TestConnection.
ubuntu_
184: [W0703, TestConnection.
ubuntu_
183: [W0702, is_machine_
- 806. By Diego Sarmentero on 2011-10-17
-
Fixed lint issues
- 807. By Diego Sarmentero on 2011-10-18
-
merge
- 808. By Diego Sarmentero on 2011-10-18
-
Fixed lint issue.
| Natalia Bidart (nataliabidart) wrote : | # |
I'm now having these test errors when running ./run-tests -qt under Linux:
=======
[ERROR]
Traceback (most recent call last):
File "/home/
self.
File "/home/
self.
exceptions.
ubuntu_
=======
[ERROR]
Traceback (most recent call last):
File "/home/
self.
File "/home/
self.
exceptions.
ubuntu_
-------
- 809. By Diego Sarmentero on 2011-10-20
-
Fixed tests.
| Diego Sarmentero (diegosarmentero) wrote : | # |
> I get the same errors today.
Fixed
- 810. By Diego Sarmentero on 2011-10-20
-
Reverted commented code
| Natalia Bidart (nataliabidart) wrote : | # |
Code looks good, but I would recommend these improvements:
* Do not hardcode any message for NetworkFailExce
* on is_machine_
def is_machine_
"""Return a deferred that when fired, returns if the machine is online."""
d = defer.Deferred()
def got_state(state):
"""The state was retrieved from the Network Manager."""
result = int(state) in NM_STATE_
try:
network = NetworkManagerS
except Exception, e: # pylint: disable=W0703
return d
* This test code (the same applies to the windows version):
# pylint: disable=W0703
try:
yield is_machine_
except Exception, reason:
# pylint: enable=W0703
should be written like this:
yield self.assertFail
otherwise, in your version of the code, there is no test failure if the except clause was not exercised.
* Can you also call patch in the windows tests instead of "FakeWininet.
* No need to change this, but using "d" as a variable, in the twisted context, usually means that the 'd' is a deferred. In the TestConnection tests, you're using as the result of the deferred, so is usually a better choice to use "result = yield <the_deferred>".
- 811. By Diego Sarmentero on 2011-10-24
-
reverting changes
- 812. By Diego Sarmentero on 2011-10-24
-
Reverted changes from success page upload by mistake.
| Natalia Bidart (nataliabidart) wrote : | # |
* Lint error:
ubuntu_
145: [W0703, is_machine_
* Also, there is no need to define and call super on __init__ in the NetworkFailExce
* This docstring is not pep-257 correct:
"""Test the state of the connection.
This TestCase tests over all the connection states possible."""
It should be:
"""Test the state of the connection.
This TestCase tests over all the connection states possible.
"""
* Remember to fix the test test_is_
- 813. By Diego Sarmentero on 2011-10-28
-
Fixed test and lint issues.
| Natalia Bidart (nataliabidart) wrote : | # |
I guess this is a typo:
"""Return a deferred that when fired, will return True if the
machine is online."""
since that is not a pep-257 compliant docstring. You could use the same docstring as in the linux implementation.
| Natalia Bidart (nataliabidart) wrote : | # |
Also, running the suite gives me errors, but trunk works OK:
=======
[FAIL]
Traceback (most recent call last):
File "/usr/lib/
raise problem
ubuntuone.
ubuntuone.
=======
[FAIL]
Traceback (most recent call last):
File "/usr/lib/
raise problem
ubuntuone.
ubuntuone.
- 814. By Diego Sarmentero on 2011-11-07
-
merge
- 815. By Diego Sarmentero on 2011-11-07
-
merge
- 816. By Diego Sarmentero on 2011-11-07
-
Fixed tests and lint issue.
- 817. By Diego Sarmentero on 2011-11-07
-
Tests fixed.
| Natalia Bidart (nataliabidart) wrote : | # |
Looks good!
Please fix the docstring
(01:59:04 PM) nessita: def is_machine_
(01:59:04 PM) nessita: """Return a deferred that when fired, will return True if the
(01:59:04 PM) nessita: machine is online."""
before landing.
- 818. By Diego Sarmentero on 2011-11-07
-
Fixed docstring.
- 819. By Diego Sarmentero on 2011-11-11
-
merge
- 820. By Diego Sarmentero on 2011-11-14
-
success ui updated
- 821. By Diego Sarmentero on 2011-11-14
-
merge
- 822. By Diego Sarmentero on 2011-11-14
-
success integration.
| Alejandro J. Cura (alecu) wrote : | # |
The branch looks great!
----
Just a small request:
Since is_machine_
def is_machine_
"""Return a deferred that when fired, returns if the machine is online."""
try:
wininet = windll.wininet
flags = DWORD()
connected = wininet.
return defer.succeed(
except Exception, e:
return defer.fail(
- 823. By Diego Sarmentero on 2012-01-04
-
merge
- 824. By Diego Sarmentero on 2012-01-04
-
is_machine_connect improved.

The method is_machine_ connected should return something, no? Either a boolean if the result is synchronous, or a deferred.