コード例 #1
0
ファイル: test_outbound.py プロジェクト: yarpc/yarpc-python
def test_bad_request_error(status_code, msg):
    class BadRequestApp(tornado.web.RequestHandler):
        def post(self):
            self.write(msg)
            self.set_status(status_code)

    app = tornado.web.Application([
        (r"/", BadRequestApp),
    ])
    app.listen(8879)

    outbound = HTTPOutbound('http://localhost:%s' % 8879)

    with pytest.raises(BadRequestError) as e:
        yield outbound.call(Request())

    e = e.value
    assert str(e) == msg
コード例 #2
0
ファイル: test_outbound.py プロジェクト: yarpc/yarpc-python
def test_unexpected_error(status_code, msg):
    msg = 'error for procedure "None" of service "None": %s' % msg

    class UnexpectedErrorApp(tornado.web.RequestHandler):
        def post(self):
            self.write(msg)
            self.set_status(status_code)

    app = tornado.web.Application([
        (r"/", UnexpectedErrorApp),
    ])
    app.listen(8879)

    outbound = HTTPOutbound('http://localhost:%s' % 8879)

    with pytest.raises(UnexpectedError) as e:
        yield outbound.call(Request())

    e = e.value
    assert str(e) == msg