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
=== modified file 'desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py'
--- desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py 2010-12-17 15:59:00 +0000
+++ desktopcouch/application/plugins/tests/test_ubuntuone_pairing.py 2011-01-03 17:31:11 +0000
@@ -18,30 +18,29 @@
1818
19"""Tests for the Ubuntu One pairing."""19"""Tests for the Ubuntu One pairing."""
2020
21import ubuntu_sso
2122
22import testtools23from mocker import MockerTestCase
23from mocker import Mocker
2424
25from desktopcouch.application.plugins import ubuntuone_pairing as uone25from desktopcouch.application.plugins import ubuntuone_pairing as uone
26from desktopcouch.application.plugins.ubuntuone_pairing import (26from desktopcouch.application.plugins.ubuntuone_pairing import (
27 pair_with_ubuntuone, U1_PAIR_RECORD, MAP_JS)27 pair_with_ubuntuone, U1_PAIR_RECORD, MAP_JS)
2828
2929
30class TestUbuntonePairing(testtools.TestCase):30class TestUbuntonePairing(MockerTestCase):
31 """Tests for Ubuntu One Pairing."""31 """Tests for Ubuntu One Pairing."""
3232
33 def setUp(self):33 def setUp(self):
34 """setup each test"""34 """setup each test"""
35 super(TestUbuntonePairing, self).setUp()35 super(TestUbuntonePairing, self).setUp()
36 # set a number of mocks that are used in all tests36 # set a number of mocks that are used in all tests
37 self.mocker = Mocker()
38 self.couchdb = self.mocker.mock()37 self.couchdb = self.mocker.mock()
39 self.put_static_paired_service = self.mocker.replace(38 self.put_static_paired_service = self.mocker.replace(
40 'desktopcouch.application.pair.couchdb_pairing.couchdb_io.' +39 'desktopcouch.application.pair.couchdb_pairing.couchdb_io.' +
41 'put_static_paired_service')40 'put_static_paired_service')
4241
43 def test_pair_with_ubuntuone_no_view(self):42 def test_pair_with_ubuntuone_no_view(self):
44 """Tests that when the view is not present it is indeed created."""43 """Test that when the view is not present it is indeed created."""
45 self.couchdb.view_exists(U1_PAIR_RECORD, U1_PAIR_RECORD)44 self.couchdb.view_exists(U1_PAIR_RECORD, U1_PAIR_RECORD)
46 self.mocker.result(False)45 self.mocker.result(False)
47 # we are interested in the fact that the view is created46 # we are interested in the fact that the view is created
@@ -100,13 +99,11 @@
100 self.mocker.verify()99 self.mocker.verify()
101100
102101
103class TestUbuntuOnePlugin(testtools.TestCase):102class TestUbuntuOnePlugin(MockerTestCase):
104 """Test the signal handling in the plug-in."""103 """Test the signal handling in the plug-in."""
105104
106 def setUp(self):105 def setUp(self):
107 super(TestUbuntuOnePlugin, self).setUp()106 super(TestUbuntuOnePlugin, self).setUp()
108 self.mocker = Mocker()
109 self._bus = self.mocker.mock()
110 self.called = False107 self.called = False
111108
112 def test_got_new_credentials_other(self):109 def test_got_new_credentials_other(self):
@@ -131,4 +128,30 @@
131128
132 def test_listen_to_dbus(self):129 def test_listen_to_dbus(self):
133 """Test that listening to credentails works."""130 """Test that listening to credentails works."""
134 uone.listen_to_dbus(bus=self._bus)131 session_class = self.mocker.replace("dbus.SessionBus")
132 iface_class = self.mocker.replace("dbus.Interface")
133
134 session_class()
135 bus = self.mocker.mock()
136 self.mocker.result(bus)
137
138 iface = ubuntu_sso.DBUS_CREDENTIALS_IFACE
139 bus.add_signal_receiver(handler_function=uone.got_new_credentials,
140 signal_name='CredentialsFound',
141 dbus_interface=iface)
142
143 bus.get_object(ubuntu_sso.DBUS_BUS_NAME,
144 ubuntu_sso.DBUS_CREDENTIALS_PATH,
145 follow_name_owner_changes=True)
146 an_obj = self.mocker.mock()
147 self.mocker.result(an_obj)
148
149 iface_class(an_obj, dbus_interface=iface)
150 sso_backend = self.mocker.mock()
151 self.mocker.result(sso_backend)
152
153 sso_backend.find_credentials(uone.APP_NAME, {})
154
155 self.mocker.replay()
156
157 uone.listen_to_dbus()
135158
=== modified file 'desktopcouch/application/plugins/ubuntuone_pairing.py'
--- desktopcouch/application/plugins/ubuntuone_pairing.py 2010-12-17 15:59:00 +0000
+++ desktopcouch/application/plugins/ubuntuone_pairing.py 2011-01-03 17:31:11 +0000
@@ -70,17 +70,25 @@
70 pair_with_ubuntuone()70 pair_with_ubuntuone()
7171
7272
73def listen_to_dbus(bus=None):73def listen_to_dbus():
74 """Set up the signal handler on D-Bus for Ubuntu One pairing."""74 """Set up the signal handler on D-Bus for Ubuntu One pairing."""
75 if not bus:75 import dbus
76 import dbus76 bus = dbus.SessionBus()
77 bus = dbus.SessionBus()
7877
79 try:78 try:
80 from ubuntu_sso import DBUS_IFACE_CRED_NAME79 import ubuntu_sso
80
81 iface = ubuntu_sso.DBUS_CREDENTIALS_IFACE
81 bus.add_signal_receiver(handler_function=got_new_credentials,82 bus.add_signal_receiver(handler_function=got_new_credentials,
82 signal_name='CredentialsFound',83 signal_name='CredentialsFound',
83 dbus_interface=DBUS_IFACE_CRED_NAME)84 dbus_interface=iface)
85
86 obj = bus.get_object(ubuntu_sso.DBUS_BUS_NAME,
87 ubuntu_sso.DBUS_CREDENTIALS_PATH,
88 follow_name_owner_changes=True)
89 sso_backend = dbus.Interface(obj, dbus_interface=iface)
90 sso_backend.find_credentials(APP_NAME, {})
91
84 except ImportError:92 except ImportError:
85 logging.info('Ubuntu SSO is not available.')93 logging.info('Ubuntu SSO is not available.')
8694

Subscribers

People subscribed via source and target branches