Merge lp:~dobey/ubuntu-sso-client/fix-no-dbus into lp:ubuntu-sso-client

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 969
Merged at revision: 967
Proposed branch: lp:~dobey/ubuntu-sso-client/fix-no-dbus
Merge into: lp:ubuntu-sso-client
Diff against target: 84 lines (+65/-1)
2 files modified
ubuntu_sso/main/linux.py (+6/-1)
ubuntu_sso/main/tests/test_linux.py (+59/-0)
To merge this branch: bzr merge lp:~dobey/ubuntu-sso-client/fix-no-dbus
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Alejandro J. Cura (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+110083@code.launchpad.net

Commit message

Trap DBusException when getting the SessionBus, and add a test case for it

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

r968 looks good.

review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Code looks good; all tests pass on windows.

review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1 for tests on MAC OS

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (173.2 KiB)

The attempt to merge lp:~dobey/ubuntu-sso-client/fix-no-dbus into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

*** Running GTK test suite for ubuntu_sso ***
Starting squid version...
Waiting for squid to start....
ubuntu_sso.main.tests.test_common
  BaseTestCase
    runTest ... [OK]
  CredentialsManagementClearTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementFindTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_find_credentials_with_error_cb ... [OK]
    test_find_credentials_with_success_cb ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementNotFindTestCase
    test_backend_called ... [OK]
    test_does_not_block ... [OK]
    test_find_credentials_with_error_cb ... [OK]
    test_find_credentials_with_success_cb ... [OK]
    test_handles_error ... [OK]
  CredentialsManagementOpsTestCase
    test_login ... [OK]
    test_login_email_password ... [OK]
    test_register ... [OK]
  CredentialsManagementParamsTestCase
    test_login ... [OK]
    test_login_email_password ... [OK]
    test_register ... [OK]
  CredentialsManagementRefCountingTestCase
    test_authorization_denied ... [OK]
    test_autorization_denied_when_ref_count_is_not_positive ... [OK]
    test_clear_credentials ... [OK]
    test_credentials_cleared ... [OK]
    test_credentials_cleared_when_ref_count_is_not_positive ... [OK]
    test_credentials_error ... [OK]
    test_credentials_error_when_ref_count_is_not_positive ... [OK]
    test_credentials_found ... [OK]
    test_credentials_found_when_ref_count_is_not_positive ... [OK]
    test_credentials_not_found ... [OK]
    test_credentials_not_found_when_ref_count_is_not_positive ... [OK]
    test_credentials_stored ... [OK]
    test_credentials_stored_when_ref_count_is_not_positive ... [OK]
    test_find_credentials ... ...

969. By dobey

Fix lint issues

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/main/linux.py'
2--- ubuntu_sso/main/linux.py 2012-04-10 10:43:48 +0000
3+++ ubuntu_sso/main/linux.py 2012-06-13 16:53:19 +0000
4@@ -342,10 +342,15 @@
5
6 def __init__(self, root):
7 self.root = root
8- self.bus = dbus.SessionBus()
9 self.sso_login = None
10 self.cred_manager = None
11
12+ try:
13+ self.bus = dbus.SessionBus()
14+ except dbus.service.DBusException as e:
15+ logger.exception(e)
16+ shutdown_func()
17+
18 def start(self):
19 """Start listening, nothing async to be done in this platform."""
20 # Register DBus service for making sure we run only one instance
21
22=== added file 'ubuntu_sso/main/tests/test_linux.py'
23--- ubuntu_sso/main/tests/test_linux.py 1970-01-01 00:00:00 +0000
24+++ ubuntu_sso/main/tests/test_linux.py 2012-06-13 16:53:19 +0000
25@@ -0,0 +1,59 @@
26+# -*- coding: utf-8 -*-
27+#
28+# Copyright 2012 Canonical Ltd.
29+#
30+# This program is free software: you can redistribute it and/or modify it
31+# under the terms of the GNU General Public License version 3, as published
32+# by the Free Software Foundation.
33+#
34+# This program is distributed in the hope that it will be useful, but
35+# WITHOUT ANY WARRANTY; without even the implied warranties of
36+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
37+# PURPOSE. See the GNU General Public License for more details.
38+#
39+# You should have received a copy of the GNU General Public License along
40+# with this program. If not, see <http://www.gnu.org/licenses/>.
41+#
42+# In addition, as a special exception, the copyright holders give
43+# permission to link the code of portions of this program with the
44+# OpenSSL library under certain conditions as described in each
45+# individual source file, and distribute linked combinations
46+# including the two.
47+# You must obey the GNU General Public License in all respects
48+# for all of the code used other than OpenSSL. If you modify
49+# file(s) with this exception, you may extend this exception to your
50+# version of the file(s), but you are not obligated to do so. If you
51+# do not wish to do so, delete this exception statement from your
52+# version. If you delete this exception statement from all source
53+# files in the program, then also delete it here.
54+"""Tests for the main SSO Linux client code."""
55+
56+# pylint: disable=C0103
57+do_tests = False
58+try:
59+ import dbus
60+ import dbus.service
61+ from ubuntu_sso.main import linux as main
62+ do_tests = True
63+except ImportError:
64+ do_tests = False
65+# pylint enable=C0103
66+
67+from ubuntuone.devtools.testcases import BaseTestCase, skipIf
68+
69+
70+@skipIf(do_tests != True, 'Tests only work with DBus and linux imports.')
71+class LinuxProxyTestCase(BaseTestCase):
72+ """Test some Linux specific cases."""
73+
74+ def test_dbus_missing_exists_clean(self):
75+ """Test that dbus-daemon not being available gives us a clean exit."""
76+ def patched(*args, **kwargs):
77+ """Method to patch in for testing."""
78+ raise dbus.service.DBusException(
79+ 'org.freedesktop.DBus.Error.NoServer')
80+
81+ self.patch(dbus, "SessionBus", patched)
82+ self.patch(main, "shutdown_func", patched)
83+ self.assertRaises(dbus.service.DBusException,
84+ main.UbuntuSSOProxy, None)

Subscribers

People subscribed via source and target branches