Merge lp:~ken-vandine/friends/unsupported_handling into lp:friends

Proposed by Ken VanDine
Status: Merged
Merged at revision: 8
Proposed branch: lp:~ken-vandine/friends/unsupported_handling
Merge into: lp:friends
Diff against target: 38 lines (+15/-2)
2 files modified
friends/tests/test_account.py (+9/-0)
friends/utils/account.py (+6/-2)
To merge this branch: bzr merge lp:~ken-vandine/friends/unsupported_handling
Reviewer Review Type Date Requested Status
Super Friends Pending
Review via email: mp+130170@code.launchpad.net

Description of the change

Gracefully fail to load accounts for unsupported protocols

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'friends/tests/test_account.py'
2--- friends/tests/test_account.py 2012-10-13 22:14:25 +0000
3+++ friends/tests/test_account.py 2012-10-17 16:29:24 +0000
4@@ -195,6 +195,15 @@
5 manager.add_new_account(self.account_service)
6 self.assertIn('faker/than fake', manager._accounts)
7
8+ def test_account_manager_add_new_account_unsupported(self):
9+ mock = self.account_service.get_account()
10+ mock.get_provider_name.return_value = 'no service'
11+ def refresh():
12+ pass
13+ manager = AccountManager(refresh)
14+ manager.add_new_account(mock.account_service)
15+ self.assertNotIn('no service', manager._accounts)
16+
17 def test_account_manager_enabled_event(self):
18 # Mimic a reaction to the enabled-event callback.
19 refreshed = False
20
21=== modified file 'friends/utils/account.py'
22--- friends/utils/account.py 2012-10-13 22:14:25 +0000
23+++ friends/utils/account.py 2012-10-17 16:29:24 +0000
24@@ -79,8 +79,12 @@
25 self._callback()
26
27 def add_new_account(self, account_service):
28- new_account = Account(account_service)
29- self._accounts[new_account.id] = new_account
30+ try:
31+ new_account = Account(account_service)
32+ self._accounts[new_account.id] = new_account
33+ except UnsupportedProtocolError as error:
34+ log.info(error)
35+
36
37 def get_all(self):
38 return self._accounts.values()

Subscribers

People subscribed via source and target branches

to all changes: