Exemple #1
0
    def test_blocks_rate_limited(self):
        self.mox.StubOutWithMock(FakeSource, 'get_blocklist')
        FakeSource.get_blocklist().AndRaise(
            source.RateLimited('foo', partial=[]))
        self.mox.ReplayAll()

        resp = app.application.get_response('/fake/123/@blocks/')
        self.assertEqual(429, resp.status_int)
Exemple #2
0
    def test_load_blocklist_rate_limited(self):
        source = FakeSource(id='x')
        self.mox.StubOutWithMock(source.gr_source, 'get_blocklist_ids')
        source.gr_source.get_blocklist_ids().AndRaise(
            gr_source.RateLimited(partial=[4, 5]))
        self.mox.ReplayAll()

        source.load_blocklist()
        self.assertEqual([4, 5], source.blocked_ids)
Exemple #3
0
    def test_blocks_rate_limited_partial(self):
        self.mox.StubOutWithMock(FakeSource, 'get_blocklist')
        blocks = [{'blockee': '1'}, {'blockee': '2'}]
        FakeSource.get_blocklist().AndRaise(
            source.RateLimited('foo', partial=blocks))
        self.mox.ReplayAll()

        resp = app.application.get_response('/fake/123/@blocks/')
        self.assertEqual(200, resp.status_int)
        self.assert_equals({'items': blocks}, json_loads(resp.body))