コード例 #1
0
 def on_response(self, *consumed):
     assert len(consumed) <= 4
     c1, c2, c3, c4 = (consumed * 4)[:4]
     remaining = (2300 - c1, 4500 - c2, 8800 - c3, 105600 - c4)
     now = datetime.utcnow().replace(tzinfo=utc)
     ts_now = int((now - EPOCH).total_seconds())
     reset = (ts_now + 15*60, ts_now + 30*60, ts_now + 60*60, ts_now + 24*60*60)
     watcher.on_response(None, result=NS(headers={
         'X-RateLimit': ', '.join(map(str, consumed)),
         'X-RateLimit-Remaining': ', '.join(map(str, remaining)),
         'X-RateLimit-Reset': ', '.join(map(str, reset)),
     }))
コード例 #2
0
ファイル: test_payio.py プロジェクト: devmiyax/liberapay.com
 def on_response(self, *consumed):
     assert len(consumed) <= 4
     c1, c2, c3, c4 = (consumed * 4)[:4]
     remaining = (2300 - c1, 4500 - c2, 8800 - c3, 105600 - c4)
     now = datetime.utcnow().replace(tzinfo=utc)
     ts_now = int((now - EPOCH).total_seconds())
     reset = (ts_now + 15*60, ts_now + 30*60, ts_now + 60*60, ts_now + 24*60*60)
     watcher.on_response(None, result=NS(headers={
         'X-RateLimit': ', '.join(map(str, consumed)),
         'X-RateLimit-Remaining': ', '.join(map(str, remaining)),
         'X-RateLimit-Reset': ', '.join(map(str, reset)),
     }))
コード例 #3
0
 def test_mangopay_watcher_handles_errors_gracefully(self):
     with mock.patch.object(self.website, 'tell_sentry') as tell_sentry:
         watcher.on_response(None, result=None)
         assert tell_sentry.called
コード例 #4
0
ファイル: test_payio.py プロジェクト: devmiyax/liberapay.com
 def test_mangopay_watcher_handles_errors_gracefully(self):
     with mock.patch.object(self.website, 'tell_sentry') as tell_sentry:
         watcher.on_response(None, result=None)
         assert tell_sentry.called