Exemplo n.º 1
0
    def test_retry_failed(self):
        srv = yield ToyServer.from_test(self)

        @srv.app.route('/<int:code>')
        def route(req, code):
            req.setResponseCode(code)

        def send(code):
            return treq.get("%s/%s" % (srv.url, code), persistent=False)

        self.assertFalse(retry_failed((yield send(200))))
        self.assertFalse(retry_failed((yield send(201))))
        self.assertFalse(retry_failed((yield send(400))))
        self.assertFalse(retry_failed((yield send(404))))
        self.assertTrue(retry_failed((yield send(500))))
        self.assertTrue(retry_failed((yield send(504))))
        self.assertTrue(retry_failed((yield send(599))))