Skip to content

Commit

Permalink
mf2 handlers: handle DisableSource
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Jul 26, 2016
1 parent 145d523 commit 5ffb250
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion handlers.py
Expand Up @@ -151,7 +151,9 @@ def get(self, type, source_short_name, string_id, *ids):
logging.info('Fetching %s', label)
try:
obj = self.get_item(*ids)
except Exception, e:
except models.DisableSource as e:
self.abort(401, "Bridgy's access to your account has expired. Please visit https://brid.gy/ to refresh it!")
except Exception as e:
# pass through all API HTTP errors if we can identify them
code, body = util.interpret_http_exception(e)
if not code and util.is_connection_failure(e):
Expand Down
10 changes: 10 additions & 0 deletions test/test_handlers.py
Expand Up @@ -175,6 +175,16 @@ def test_connection_failures_503(self):
resp = self.check_response('/post/fake/%s/000', expected_status=503)
self.assertEqual('FakeSource error:\nTry again pls', resp.body)

def test_handle_disable_source(self):
self.mox.StubOutWithMock(testutil.FakeSource, 'get_activities')
testutil.FakeSource.get_activities(
activity_id='000', user_id=self.source.key.string_id()
).AndRaise(models.DisableSource())
self.mox.ReplayAll()

resp = self.check_response('/post/fake/%s/000', expected_status=401)
self.assertIn("Bridgy's access to your account has expired", resp.body)

def test_comment(self):
FakeGrSource.comment = {
'id': 'tag:fa.ke,2013:a1-b2.c3', # test alphanumeric id (like G+)
Expand Down

0 comments on commit 5ffb250

Please sign in to comment.