test_reverse_proxy.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:simphony-remote 作者: simphony 项目源码 文件源码
def test_reverse_proxy_operations(self):
        coroutine_out = None

        @gen.coroutine
        def mock_api_request(self, *args, **kwargs):
            nonlocal coroutine_out
            yield gen.sleep(0.1)
            coroutine_out = dict(args=args, kwargs=kwargs)

        reverse_proxy = ReverseProxy(
            endpoint_url="http://fake/api",
            api_token="token")
        reverse_proxy._reverse_proxy = Mock(spec=orm.Proxy)
        reverse_proxy._reverse_proxy.api_request = mock_api_request

        yield reverse_proxy.register("/hello/from/me/",
                                     "http://localhost:12312/")

        self.assertEqual(coroutine_out["kwargs"]["method"], "POST")

        yield reverse_proxy.unregister("/hello/from/me/")

        self.assertEqual(coroutine_out["kwargs"]["method"], "DELETE")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号