def test_perm_roles_decorator(http_client, base_url, app_base_handlers, monkeypatch):
with pytest.raises(HTTPError) as e:
await http_client.fetch(base_url + '/test/api_test_model_dec/', method='GET')
async def success_get_roles(self):
return ['admin']
monkeypatch.setattr(DecTestHandler, 'get_roles', success_get_roles)
res = await http_client.fetch(base_url + '/test/api_test_model_dec/', method='GET')
assert res.code == 200
async def error_is_auth(self):
return False
monkeypatch.setattr(DecTestHandler, 'is_auth', error_is_auth)
with pytest.raises(HTTPError) as e:
await http_client.fetch(base_url + '/test/api_test_model_dec/', method='GET')
评论列表
文章目录