Merge lp:~nataliabidart/desktopcouch/find-u1-credentials into lp:desktopcouch

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 245
Merged at revision: 242
Proposed branch: lp:~nataliabidart/desktopcouch/find-u1-credentials
Merge into: lp:desktopcouch
Diff against target: 120 lines (+46/-15)
2 files modified
desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py (+32/-9)
desktopcouch/application/plugins/ubuntuone_pairing.py (+14/-6)
To merge this branch: bzr merge lp:~nataliabidart/desktopcouch/find-u1-credentials
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
dobey (community) Approve
Review via email: mp+45032@code.launchpad.net

Commit message

ubuntu_sso.find_credentials must be called when pairing ubuntu one records, so we can use U1 credentials if already on the system (LP: #694495).

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Samuele Pedroni (pedronis) wrote :

looks good, I still think even if ImportError is quite specific it would be better if the try except would bracket only the imports and not so much code

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

The attempt to merge lp:~nataliabidart/desktopcouch/find-u1-credentials into lp:desktopcouch failed. Below is the output from the failed tests.

Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmp6bDFA6/data/couchdb.html
desktopcouch.application.tests.test_start_local_couchdb
  TestUpdateDesignDocuments
    test_create_databases_and_design_docs ... [OK]
desktopcouch.application.tests.test_service
  TestService
    test_start_desktopcouch_replication ... [OK]
    test_start_new_desktopcouch_extensions ... [OK]
    test_start_new_desktopcouch_no_extensions ... [OK]
desktopcouch.application.tests.test_local_files
  TestKeyringIntegration
    test_with_auth ... [OK]
    test_with_no_auth ... [OK]
  TestLocalFiles
    test_all_files_returned ... [OK]
    test_bind_address ... [OK]
    test_couch_chain_ini_files ... [OK]
    test_xdg_overwrite_works ... [OK]
desktopcouch.application.tests.test_replication
  TestReplication
    test_creation ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpEnB1xn/data/couchdb.html
                                                     [OK]
  TestUbuntuoneReplication
    test_exclusion ... Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpfnK3HZ/data/couchdb.html
                                                    [OK]
desktopcouch.application.migration.tests.test_migration
  TestMigration
    test_migration_deleted_flag_to_trash ... test_migration_deleted_flag_to_trash
apple
                              [OK]
    test_migration_script_is_run ... test_migration_script_is_run
                                      [OK]
    test_migration_script_is_run_and_can_access_view ... test_migration_script_is_run_and_can_access_view
                  [OK]
  TestRegistration
    test_register_migration_is_added_to_the_registry ... [OK]
desktopcouch.application.platform.windows.tests.test_keyring
  TestKeyring
    test_get_oauth_data ... [OK]
    test_get_user_name_password ... [OK]
    test_get_user_name_password_no_key ... [OK]
    test_get_user_name_password_no_value ... [OK]
desktopcouch.application.pair.tests.test_couchdb_io
  TestCouchdbIo
    test_get_database_names_replicatable ... [OK]
    test_get_my_host_unique_id ... [OK]
    test_mkuri ... [OK]
    test_obsfuscation ... [OK]
    test_put_dynamic_paired_host ... [OK]
    test_put_static_paired_servic...

244. By Natalia Bidart

Removed unused import.

245. By Natalia Bidart

Merged trunk in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py'
2--- desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py 2010-12-17 15:59:00 +0000
3+++ desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py 2011-01-03 17:31:11 +0000
4@@ -18,30 +18,29 @@
5
6 """Tests for the Ubuntu One pairing."""
7
8+import ubuntu_sso
9
10-import testtools
11-from mocker import Mocker
12+from mocker import MockerTestCase
13
14 from desktopcouch.application.plugins import ubuntuone_pairing as uone
15 from desktopcouch.application.plugins.ubuntuone_pairing import (
16 pair_with_ubuntuone, U1_PAIR_RECORD, MAP_JS)
17
18
19-class TestUbuntonePairing(testtools.TestCase):
20+class TestUbuntonePairing(MockerTestCase):
21 """Tests for Ubuntu One Pairing."""
22
23 def setUp(self):
24 """setup each test"""
25 super(TestUbuntonePairing, self).setUp()
26 # set a number of mocks that are used in all tests
27- self.mocker = Mocker()
28 self.couchdb = self.mocker.mock()
29 self.put_static_paired_service = self.mocker.replace(
30 'desktopcouch.application.pair.couchdb_pairing.couchdb_io.' +
31 'put_static_paired_service')
32
33 def test_pair_with_ubuntuone_no_view(self):
34- """Tests that when the view is not present it is indeed created."""
35+ """Test that when the view is not present it is indeed created."""
36 self.couchdb.view_exists(U1_PAIR_RECORD, U1_PAIR_RECORD)
37 self.mocker.result(False)
38 # we are interested in the fact that the view is created
39@@ -100,13 +99,11 @@
40 self.mocker.verify()
41
42
43-class TestUbuntuOnePlugin(testtools.TestCase):
44+class TestUbuntuOnePlugin(MockerTestCase):
45 """Test the signal handling in the plug-in."""
46
47 def setUp(self):
48 super(TestUbuntuOnePlugin, self).setUp()
49- self.mocker = Mocker()
50- self._bus = self.mocker.mock()
51 self.called = False
52
53 def test_got_new_credentials_other(self):
54@@ -131,4 +128,30 @@
55
56 def test_listen_to_dbus(self):
57 """Test that listening to credentails works."""
58- uone.listen_to_dbus(bus=self._bus)
59+ session_class = self.mocker.replace("dbus.SessionBus")
60+ iface_class = self.mocker.replace("dbus.Interface")
61+
62+ session_class()
63+ bus = self.mocker.mock()
64+ self.mocker.result(bus)
65+
66+ iface = ubuntu_sso.DBUS_CREDENTIALS_IFACE
67+ bus.add_signal_receiver(handler_function=uone.got_new_credentials,
68+ signal_name='CredentialsFound',
69+ dbus_interface=iface)
70+
71+ bus.get_object(ubuntu_sso.DBUS_BUS_NAME,
72+ ubuntu_sso.DBUS_CREDENTIALS_PATH,
73+ follow_name_owner_changes=True)
74+ an_obj = self.mocker.mock()
75+ self.mocker.result(an_obj)
76+
77+ iface_class(an_obj, dbus_interface=iface)
78+ sso_backend = self.mocker.mock()
79+ self.mocker.result(sso_backend)
80+
81+ sso_backend.find_credentials(uone.APP_NAME, {})
82+
83+ self.mocker.replay()
84+
85+ uone.listen_to_dbus()
86
87=== modified file 'desktopcouch/application/plugins/ubuntuone_pairing.py'
88--- desktopcouch/application/plugins/ubuntuone_pairing.py 2010-12-17 15:59:00 +0000
89+++ desktopcouch/application/plugins/ubuntuone_pairing.py 2011-01-03 17:31:11 +0000
90@@ -70,17 +70,25 @@
91 pair_with_ubuntuone()
92
93
94-def listen_to_dbus(bus=None):
95+def listen_to_dbus():
96 """Set up the signal handler on D-Bus for Ubuntu One pairing."""
97- if not bus:
98- import dbus
99- bus = dbus.SessionBus()
100+ import dbus
101+ bus = dbus.SessionBus()
102
103 try:
104- from ubuntu_sso import DBUS_IFACE_CRED_NAME
105+ import ubuntu_sso
106+
107+ iface = ubuntu_sso.DBUS_CREDENTIALS_IFACE
108 bus.add_signal_receiver(handler_function=got_new_credentials,
109 signal_name='CredentialsFound',
110- dbus_interface=DBUS_IFACE_CRED_NAME)
111+ dbus_interface=iface)
112+
113+ obj = bus.get_object(ubuntu_sso.DBUS_BUS_NAME,
114+ ubuntu_sso.DBUS_CREDENTIALS_PATH,
115+ follow_name_owner_changes=True)
116+ sso_backend = dbus.Interface(obj, dbus_interface=iface)
117+ sso_backend.find_credentials(APP_NAME, {})
118+
119 except ImportError:
120 logging.info('Ubuntu SSO is not available.')
121

Subscribers

People subscribed via source and target branches