tests.py 文件源码

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

项目:sdining 作者: Lurance 项目源码 文件源码
def test_rate(self):
        req = rf.post('/')

        class TwiceView(RatelimitMixin, View):
            ratelimit_key = 'ip'
            ratelimit_rate = '2/m'

            def post(self, request, *args, **kwargs):
                return request.limited
            get = post

        twice = TwiceView.as_view()

        assert not twice(req), 'First request is not limited.'
        assert not twice(req), 'Second request is not limited.'
        assert twice(req), 'Third request is limited.'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号