Merge lp:~robru/friends/neuter into lp:friends

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 259
Merged at revision: 256
Proposed branch: lp:~robru/friends/neuter
Merge into: lp:friends
Diff against target: 156 lines (+65/-0)
2 files modified
friends/service/dispatcher.py (+23/-0)
friends/tests/test_dispatcher.py (+42/-0)
To merge this branch: bzr merge lp:~robru/friends/neuter
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ken VanDine Pending
Super Friends Pending
Review via email: mp+226724@code.launchpad.net

Commit message

Neuter friends-dispatcher so that no messages can be sent or received.

To post a comment you must log in.
lp:~robru/friends/neuter updated
257. By Robert Bruce Park

Fix tests too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

I don't understand this jenkins failure and I can't reproduce it locally

lp:~robru/friends/neuter updated
258. By Robert Bruce Park

Call success callback for async methods.

259. By Robert Bruce Park

Pass an argument to success()

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:259
http://jenkins.qa.ubuntu.com/job/friends-ci/60/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/friends-utopic-amd64-ci/3

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/friends-ci/60/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'friends/service/dispatcher.py'
--- friends/service/dispatcher.py 2013-06-18 22:00:44 +0000
+++ friends/service/dispatcher.py 2014-07-14 20:30:39 +0000
@@ -119,6 +119,10 @@
119119
120 log.debug('Refresh requested')120 log.debug('Refresh requested')
121121
122 # Friends is deprecated, the API is exposed for compatibility,
123 # but calling the methods does nothing.
124 return
125
122 # account.protocol() starts a new thread and then returns126 # account.protocol() starts a new thread and then returns
123 # immediately, so there is no delay or blocking during the127 # immediately, so there is no delay or blocking during the
124 # execution of this method.128 # execution of this method.
@@ -162,6 +166,10 @@
162 service.Do('search', '', 'search terms') # Searches all accounts.166 service.Do('search', '', 'search terms') # Searches all accounts.
163 service.Do('list', '6', 'list_id') # Fetch a single list.167 service.Do('list', '6', 'list_id') # Fetch a single list.
164 """168 """
169 # Friends is deprecated, the API is exposed for compatibility,
170 # but calling the methods does nothing.
171 return
172
165 if account_id:173 if account_id:
166 accounts = [self.accounts.get(int(account_id))]174 accounts = [self.accounts.get(int(account_id))]
167 if None in accounts:175 if None in accounts:
@@ -202,6 +210,11 @@
202 service = dbus.Interface(obj, DBUS_INTERFACE)210 service = dbus.Interface(obj, DBUS_INTERFACE)
203 service.SendMessage('Your message')211 service.SendMessage('Your message')
204 """212 """
213 # Friends is deprecated, the API is exposed for compatibility,
214 # but calling the methods does nothing.
215 success('Warning: Friends is deprecated and has been disabled.')
216 return
217
205 sent = False218 sent = False
206 for account in self.accounts.values():219 for account in self.accounts.values():
207 if account.send_enabled:220 if account.send_enabled:
@@ -237,6 +250,11 @@
237 service = dbus.Interface(obj, DBUS_INTERFACE)250 service = dbus.Interface(obj, DBUS_INTERFACE)
238 service.SendReply('6', '34245645347345626', 'Your reply')251 service.SendReply('6', '34245645347345626', 'Your reply')
239 """252 """
253 # Friends is deprecated, the API is exposed for compatibility,
254 # but calling the methods does nothing.
255 success('Warning: Friends is deprecated and has been disabled.')
256 return
257
240 log.debug('Replying to {}, {}'.format(account_id, message_id))258 log.debug('Replying to {}, {}'.format(account_id, message_id))
241 account = self.accounts.get(int(account_id))259 account = self.accounts.get(int(account_id))
242 if account is not None:260 if account is not None:
@@ -295,6 +313,11 @@
295 Note also that the callbacks are actually optional; you are313 Note also that the callbacks are actually optional; you are
296 free to ignore error conditions at your peril.314 free to ignore error conditions at your peril.
297 """315 """
316 # Friends is deprecated, the API is exposed for compatibility,
317 # but calling the methods does nothing.
318 success('Warning: Friends is deprecated and has been disabled.')
319 return
320
298 log.debug('Uploading {} to {}'.format(uri, account_id))321 log.debug('Uploading {} to {}'.format(uri, account_id))
299 account = self.accounts.get(int(account_id))322 account = self.accounts.get(int(account_id))
300 if account is not None:323 if account is not None:
301324
=== modified file 'friends/tests/test_dispatcher.py'
--- friends/tests/test_dispatcher.py 2013-12-09 18:35:39 +0000
+++ friends/tests/test_dispatcher.py 2014-07-14 20:30:39 +0000
@@ -62,6 +62,12 @@
6262
63 self.assertIsNone(self.dispatcher.Refresh())63 self.assertIsNone(self.dispatcher.Refresh())
6464
65 # Friends is deprecated, the API is exposed for compatibility,
66 # but calling the methods does nothing.
67 assert not self.dispatcher.accounts.values.called
68 assert not account.protocol.called
69 return
70
65 self.dispatcher.accounts.values.assert_called_once_with()71 self.dispatcher.accounts.values.assert_called_once_with()
66 account.protocol.assert_called_once_with('receive')72 account.protocol.assert_called_once_with('receive')
6773
@@ -82,6 +88,12 @@
82 self.dispatcher.accounts.get.return_value = account88 self.dispatcher.accounts.get.return_value = account
8389
84 self.dispatcher.Do('like', '345', '23346356767354626')90 self.dispatcher.Do('like', '345', '23346356767354626')
91
92 # Friends is deprecated, the API is exposed for compatibility,
93 # but calling the methods does nothing.
94 assert not self.dispatcher.accounts.get.called
95 return
96
85 self.dispatcher.accounts.get.assert_called_once_with(345)97 self.dispatcher.accounts.get.assert_called_once_with(345)
86 account.protocol.assert_called_once_with(98 account.protocol.assert_called_once_with(
87 'like', '23346356767354626', success=STUB, failure=STUB)99 'like', '23346356767354626', success=STUB, failure=STUB)
@@ -97,6 +109,12 @@
97 self.dispatcher.accounts.get.return_value = None109 self.dispatcher.accounts.get.return_value = None
98110
99 self.dispatcher.Do('unlike', '6', '23346356767354626')111 self.dispatcher.Do('unlike', '6', '23346356767354626')
112
113 # Friends is deprecated, the API is exposed for compatibility,
114 # but calling the methods does nothing.
115 assert not self.dispatcher.accounts.get.called
116 return
117
100 self.dispatcher.accounts.get.assert_called_once_with(6)118 self.dispatcher.accounts.get.assert_called_once_with(6)
101 self.assertEqual(account.protocol.call_count, 0)119 self.assertEqual(account.protocol.call_count, 0)
102120
@@ -119,6 +137,12 @@
119 ]137 ]
120138
121 self.dispatcher.SendMessage('Howdy friends!')139 self.dispatcher.SendMessage('Howdy friends!')
140
141 # Friends is deprecated, the API is exposed for compatibility,
142 # but calling the methods does nothing.
143 assert not self.dispatcher.accounts.values.called
144 return
145
122 self.dispatcher.accounts.values.assert_called_once_with()146 self.dispatcher.accounts.values.assert_called_once_with()
123 account1.protocol.assert_called_once_with(147 account1.protocol.assert_called_once_with(
124 'send', 'Howdy friends!', success=STUB, failure=STUB)148 'send', 'Howdy friends!', success=STUB, failure=STUB)
@@ -132,6 +156,12 @@
132 self.dispatcher.accounts.get.return_value = account156 self.dispatcher.accounts.get.return_value = account
133157
134 self.dispatcher.SendReply('2', 'objid', '[Hilarious Response]')158 self.dispatcher.SendReply('2', 'objid', '[Hilarious Response]')
159
160 # Friends is deprecated, the API is exposed for compatibility,
161 # but calling the methods does nothing.
162 assert not self.dispatcher.accounts.get.called
163 return
164
135 self.dispatcher.accounts.get.assert_called_once_with(2)165 self.dispatcher.accounts.get.assert_called_once_with(2)
136 account.protocol.assert_called_once_with(166 account.protocol.assert_called_once_with(
137 'send_thread', 'objid', '[Hilarious Response]',167 'send_thread', 'objid', '[Hilarious Response]',
@@ -148,6 +178,12 @@
148 self.dispatcher.accounts.get.return_value = None178 self.dispatcher.accounts.get.return_value = None
149179
150 self.dispatcher.SendReply('2', 'objid', '[Hilarious Response]')180 self.dispatcher.SendReply('2', 'objid', '[Hilarious Response]')
181
182 # Friends is deprecated, the API is exposed for compatibility,
183 # but calling the methods does nothing.
184 assert not self.dispatcher.accounts.get.called
185 return
186
151 self.dispatcher.accounts.get.assert_called_once_with(2)187 self.dispatcher.accounts.get.assert_called_once_with(2)
152 self.assertEqual(account.protocol.call_count, 0)188 self.assertEqual(account.protocol.call_count, 0)
153189
@@ -170,6 +206,12 @@
170 'A thousand words',206 'A thousand words',
171 success=success,207 success=success,
172 failure=failure)208 failure=failure)
209
210 # Friends is deprecated, the API is exposed for compatibility,
211 # but calling the methods does nothing.
212 assert not self.dispatcher.accounts.get.called
213 return
214
173 self.dispatcher.accounts.get.assert_called_once_with(2)215 self.dispatcher.accounts.get.assert_called_once_with(2)
174 account.protocol.assert_called_once_with(216 account.protocol.assert_called_once_with(
175 'upload',217 'upload',

Subscribers

People subscribed via source and target branches