当前位置: 首页>>代码示例>>Python>>正文


Python FakeSource.get_activities_response方法代码示例

本文整理汇总了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()
开发者ID:notenoughneon,项目名称:bridgy,代码行数:29,代码来源:tasks_test.py

示例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)
开发者ID:notenoughneon,项目名称:bridgy,代码行数:14,代码来源:tasks_test.py

示例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)
开发者ID:notenoughneon,项目名称:bridgy,代码行数:18,代码来源:tasks_test.py

示例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()
开发者ID:notenoughneon,项目名称:bridgy,代码行数:20,代码来源:tasks_test.py

示例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)
开发者ID:notenoughneon,项目名称:bridgy,代码行数:23,代码来源:tasks_test.py

示例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()
开发者ID:notenoughneon,项目名称:bridgy,代码行数:25,代码来源:tasks_test.py


注:本文中的testutil.FakeSource.get_activities_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。