本文整理汇总了Python中testutil.FakeSource.get_activities_response方法的典型用法代码示例。如果您正苦于以下问题:Python FakeSource.get_activities_response方法的具体用法?Python FakeSource.get_activities_response怎么用?Python FakeSource.get_activities_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testutil.FakeSource
的用法示例。
在下文中一共展示了FakeSource.get_activities_response方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rate_limiting_errors
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_rate_limiting_errors(self):
"""Finish the task on rate limiting errors."""
try:
for err in (InstagramAPIError('503', 'Rate limited', '...'),
apiclient.errors.HttpError(httplib2.Response({'status': 429}), ''),
urllib2.HTTPError('url', 403, 'msg', {}, None)):
self.mox.UnsetStubs()
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag=None, min_id=None, cache=mox.IgnoreArg(),
).AndRaise(err)
self.mox.ReplayAll()
self.post_task()
source = self.sources[0].key.get()
self.assertEqual('error', source.status)
self.mox.VerifyAll()
# should have inserted a new poll task
polls = self.taskqueue_stub.GetTasks('poll')
self.assertEqual(1, len(polls))
self.assertEqual('/_ah/queue/poll', polls[0]['url'])
polls = self.taskqueue_stub.FlushQueue('poll')
finally:
self.mox.UnsetStubs()
示例2: test_poll_error
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_poll_error(self):
"""If anything goes wrong, the source status should be set to 'error'."""
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag=None, min_id=None, cache=mox.IgnoreArg(),
).AndRaise(Exception('foo'))
self.mox.ReplayAll()
self.assertRaises(Exception, self.post_task)
source = self.sources[0].key.get()
self.assertEqual('error', source.status)
示例3: test_disable_source_on_deauthorized
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_disable_source_on_deauthorized(self):
"""If the source raises DisableSource, disable it.
"""
source = self.sources[0]
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag=None, min_id=None, cache=mox.IgnoreArg(),
).AndRaise(models.DisableSource)
self.mox.ReplayAll()
source.status = 'enabled'
source.put()
self.post_task()
source = source.key.get()
self.assertEqual('disabled', source.status)
示例4: test_last_activity_id
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_last_activity_id(self):
"""We should store the last activity id seen and then send it as min_id."""
self.sources[0].set_activities(list(reversed(self.activities)))
self.post_task()
source = self.sources[0].key.get()
self.assertEqual('c', source.last_activity_id)
source.last_polled = util.EPOCH
source.put()
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag=None, min_id='c', cache=mox.IgnoreArg(),
).AndReturn({'items': []})
self.mox.ReplayAll()
self.post_task()
示例5: test_etag
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_etag(self):
"""If we see an ETag, we should send it with the next get_activities()."""
self.sources[0]._set('etag', '"my etag"')
self.post_task()
source = self.sources[0].key.get()
self.assertEqual('"my etag"', source.last_activities_etag)
source.last_polled = util.EPOCH
source.put()
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag='"my etag"', min_id='c', cache=mox.IgnoreArg(),
).AndReturn({'items': [], 'etag': '"new etag"'})
self.mox.ReplayAll()
self.post_task()
source = self.sources[0].key.get()
self.assertEqual('"new etag"', source.last_activities_etag)
示例6: test_site_specific_disable_sources
# 需要导入模块: from testutil import FakeSource [as 别名]
# 或者: from testutil.FakeSource import get_activities_response [as 别名]
def test_site_specific_disable_sources(self):
"""HTTP 401 and 400 '' for Instagram should disable the source."""
try:
for err in (urllib2.HTTPError('url', 401, 'msg', {}, StringIO.StringIO('body')),
InstagramAPIError('400', 'OAuthAccessTokenException', 'foo'),
AccessTokenRefreshError('invalid_grant'),
):
self.mox.UnsetStubs()
self.setUp()
self.mox.StubOutWithMock(FakeSource, 'get_activities_response')
FakeSource.get_activities_response(
count=mox.IgnoreArg(), fetch_replies=True, fetch_likes=True,
fetch_shares=True, etag=None, min_id=None, cache=mox.IgnoreArg(),
).AndRaise(err)
self.mox.ReplayAll()
self.post_task()
source = self.sources[0].key.get()
self.assertEqual('disabled', source.status)
finally:
self.mox.UnsetStubs()