Merge lp:~alecu/ubuntu-sso-client/other-nm-errors into lp:ubuntu-sso-client

Proposed by Alejandro J. Cura on 2012-10-05
Status: Merged
Approved by: Manuel de la Peña on 2012-10-10
Approved revision: 1005
Merged at revision: 1006
Proposed branch: lp:~alecu/ubuntu-sso-client/other-nm-errors
Merge into: lp:ubuntu-sso-client
Diff against target: 114 lines (+13/-29)
2 files modified
ubuntu_sso/networkstate/linux.py (+7/-11)
ubuntu_sso/networkstate/tests/test_linux.py (+6/-18)
To merge this branch: bzr merge lp:~alecu/ubuntu-sso-client/other-nm-errors
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-10-10
dobey (community) 2012-10-05 Approve on 2012-10-05
Review via email: mp+128272@code.launchpad.net

Commit Message

- Any error while getting the state from NM is now considered as ONLINE (LP: #1062051).

To post a comment you must log in.
dobey (dobey) :
review: Approve
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/networkstate/linux.py'
2--- ubuntu_sso/networkstate/linux.py 2012-06-22 20:03:57 +0000
3+++ ubuntu_sso/networkstate/linux.py 2012-10-05 15:01:35 +0000
4@@ -33,6 +33,7 @@
5 from twisted.internet import defer
6
7 from ubuntu_sso.networkstate import NetworkFailException
8+# pylint: disable=W0611
9 from ubuntu_sso.networkstate.networkstates import (
10 ONLINE, OFFLINE, UNKNOWN,
11
12@@ -40,12 +41,12 @@
13 NM_STATE_CONNECTED_LIST,
14 NM_STATE_DISCONNECTED_LIST,
15 )
16+# pylint: enable=W0611
17 from ubuntu_sso.logger import setup_logging
18 logger = setup_logging("ubuntu_sso.networkstate")
19
20 NM_DBUS_INTERFACE = "org.freedesktop.NetworkManager"
21 NM_DBUS_OBJECTPATH = "/org/freedesktop/NetworkManager"
22-DBUS_UNKNOWN_SERVICE = "org.freedesktop.DBus.Error.ServiceUnknown"
23
24
25 class NetworkManagerState(object):
26@@ -72,16 +73,11 @@
27
28 def got_error(self, error):
29 """Called by DBus when the state is retrieved from NM."""
30- if isinstance(error, self.dbus.exceptions.DBusException) and \
31- error.get_dbus_name() == DBUS_UNKNOWN_SERVICE:
32- logger.debug("Network Manager not present")
33- # Assuming since Network Manager is not installed,
34- # the user has connected in some other way
35- self.call_result_cb(ONLINE)
36- else:
37- logger.error("Error contacting NetworkManager: %s" %
38- str(error))
39- self.call_result_cb(UNKNOWN)
40+ # Assuming since Network Manager is not running,
41+ # the user has connected in some other way
42+ logger.error("Error contacting NetworkManager: %s" %
43+ str(error))
44+ self.call_result_cb(ONLINE)
45
46 def state_changed(self, state):
47 """Called when a signal is emmited by Network Manager."""
48
49=== modified file 'ubuntu_sso/networkstate/tests/test_linux.py'
50--- ubuntu_sso/networkstate/tests/test_linux.py 2012-05-30 17:44:13 +0000
51+++ ubuntu_sso/networkstate/tests/test_linux.py 2012-10-05 15:01:35 +0000
52@@ -56,7 +56,6 @@
53 )
54
55 from ubuntu_sso.networkstate.linux import (is_machine_connected,
56- DBUS_UNKNOWN_SERVICE,
57 NM_DBUS_INTERFACE,
58 NM_DBUS_OBJECTPATH,
59 )
60@@ -174,7 +173,7 @@
61 self.assertEqual(nms.state_signal.interface,
62 "org.freedesktop.NetworkManager")
63 self.assertEqual(self.network_changes,
64- [UNKNOWN, ONLINE, OFFLINE, ONLINE])
65+ [ONLINE, ONLINE, OFFLINE, ONLINE])
66 self.assertFalse(nms.state_signal.removed)
67
68 @inlineCallbacks
69@@ -213,15 +212,6 @@
70 yield self.assertFailure(is_machine_connected(), NetworkFailException)
71
72
73-class TestNmNotAvailableException(Exception):
74-
75- """An exception to test unavailability conditions."""
76-
77- def get_dbus_name(self):
78- """The real name of the dbus error when NM is not running."""
79- return DBUS_UNKNOWN_SERVICE
80-
81-
82 class NetworkManagerBaseTestCase(MockerTestCase):
83 """Base test case for NM state tests."""
84
85@@ -251,7 +241,6 @@
86
87 proxymock.Get(ARGS, KWARGS)
88 if exc is not None:
89- self.expect(self.dbusmock.exceptions.DBusException)
90 self.mocker.result(exc)
91 self.mocker.replay()
92
93@@ -367,16 +356,15 @@
94 def mock_except_while_getting_proxy(self, exc):
95 """Simulate an exception while getting the DBus proxy object."""
96 self.mocker.throw(exc)
97- self.expect(self.dbusmock.exceptions.DBusException)
98 self.mocker.result(exc)
99 self.mocker.replay()
100
101- def test_nm_not_installed(self):
102- """Check the case when NM is not installed."""
103- self.connect_proxy(TestNmNotAvailableException)
104- self.check_nm_error(self.assertOnline, TestNmNotAvailableException())
105+ def test_nm_check_errors(self):
106+ """Trying to reach NM fails with some error."""
107+ self.connect_proxy(Exception)
108+ self.check_nm_error(self.assertOnline, Exception())
109
110 def test_dbus_problem(self):
111 """Check the case when DBus throws some other exception."""
112 self.mock_except_while_getting_proxy(TestException)
113- self.get_nms(self.assertUnknown)
114+ self.get_nms(self.assertOnline)

Subscribers

People subscribed via source and target branches