Merge lp:~cmiller/desktopcouch/sso-app-fixes into lp:desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: Vincenzo Di Somma
Approved revision: 174
Merged at revision: 174
Proposed branch: lp:~cmiller/desktopcouch/sso-app-fixes
Merge into: lp:desktopcouch
Diff against target: 73 lines (+30/-12)
2 files modified
desktopcouch/start_local_couchdb.py (+10/-11)
desktopcouch/tests/test_start_local_couchdb.py (+20/-1)
To merge this branch: bzr merge lp:~cmiller/desktopcouch/sso-app-fixes
Reviewer Review Type Date Requested Status
Vincenzo Di Somma (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+35841@code.launchpad.net

Commit message

Fix one typo in an exception name, move default value settings higher to make exec paths irrelevant to their existence, and restructure code to make it testable and tested (LP: #641381)

To post a comment you must log in.
Revision history for this message
Manuel de la Peña (mandel) wrote :

superb!

review: Approve
Revision history for this message
Vincenzo Di Somma (vds) wrote :

Great! Thanks for fixing it so quickly! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/start_local_couchdb.py'
2--- desktopcouch/start_local_couchdb.py 2010-09-09 13:35:18 +0000
3+++ desktopcouch/start_local_couchdb.py 2010-09-17 15:31:19 +0000
4@@ -203,23 +203,22 @@
5 fp.close()
6
7
8-def update_pairing_service(sso=None):
9+def update_pairing_service(sso=None, test_import_fails=False):
10 """Update the pairing records between desktopcouch and Ubuntu One."""
11 if not sso:
12 try:
13 # get the credentials using ubuntu sso dbus
14+ if test_import_fails:
15+ raise ImportError
16 from ubuntu_sso.main import SSOCredentials
17- sso_finder = SSOCredentials()
18- except ImportErrro:
19- logging.warn("Ubuntu SSO dbus service could not be used.")
20- # test again to see if we did not get an import error
21- else:
22- sso_finder = sso
23+ sso = SSOCredentials()
24+ except ImportError:
25+ logging.info("Ubuntu SSO dbus service could not be used.")
26
27- if sso_finder:
28- credentials = sso_finder.find_credentials('Ubuntu One')
29- if credentials and len(credentials) > 0:
30- pair_with_ubuntuone()
31+ if sso:
32+ credentials = sso.find_credentials('Ubuntu One')
33+ if credentials and len(credentials) > 0:
34+ pair_with_ubuntuone()
35
36 def start_couchdb(ctx=local_files.DEFAULT_CONTEXT):
37 """Execute each step to start a desktop CouchDB."""
38
39=== modified file 'desktopcouch/tests/test_start_local_couchdb.py'
40--- desktopcouch/tests/test_start_local_couchdb.py 2010-09-08 14:08:41 +0000
41+++ desktopcouch/tests/test_start_local_couchdb.py 2010-09-17 15:31:19 +0000
42@@ -137,7 +137,7 @@
43 mocker.restore()
44 mocker.verify()
45
46- def test_pair_ubuntuone(self):
47+ def test_pair_ubuntuone_with_sso(self):
48 """ Test the pairing with ubuntu one.
49
50 Ensure that the pair ubuntu one method is called when we do have
51@@ -158,3 +158,22 @@
52 update_pairing_service(sso_mock)
53 mocker.verify()
54
55+ def test_pair_ubuntuone_without_sso(self):
56+ """ Test the pairing with ubuntu one.
57+
58+ Ensure that the pair ubuntu one method is called when we do have
59+ credentials.
60+ """
61+ from desktopcouch.start_local_couchdb import update_pairing_service
62+ mocker = Mocker()
63+ pair_ubuntu_one_mock = mocker.replace(
64+ 'desktopcouch.pair.couchdb_pairing.' +
65+ 'ubuntuone_pairing.pair_with_ubuntuone')
66+ # make the sso credentials return a dictionary with fake data
67+ mocker.result({'fake':'credential'})
68+ # pair with ubuntu one never called!
69+ mocker.replay()
70+ # call the start method to ensure that the methods are correctly called
71+ update_pairing_service(sso=None, test_import_fails=True)
72+ mocker.verify()
73+

Subscribers

People subscribed via source and target branches