LTS v21.12 Deprecations (#2306)
Co-authored-by: Néstor Pérez <25409753+prryplatypus@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import pytest
|
||||
from sanic import Sanic
|
||||
from sanic.blueprints import Blueprint
|
||||
from sanic.response import json, text
|
||||
from sanic.views import CompositionView, HTTPMethodView
|
||||
from sanic.views import HTTPMethodView
|
||||
from sanic.views import stream as stream_decorator
|
||||
|
||||
|
||||
@@ -423,33 +423,6 @@ def test_request_stream_blueprint(app):
|
||||
assert response.text == data
|
||||
|
||||
|
||||
def test_request_stream_composition_view(app):
|
||||
def get_handler(request):
|
||||
return text("OK")
|
||||
|
||||
async def post_handler(request):
|
||||
result = ""
|
||||
while True:
|
||||
body = await request.stream.read()
|
||||
if body is None:
|
||||
break
|
||||
result += body.decode("utf-8")
|
||||
return text(result)
|
||||
|
||||
view = CompositionView()
|
||||
view.add(["GET"], get_handler)
|
||||
view.add(["POST"], post_handler, stream=True)
|
||||
app.add_route(view, "/composition_view")
|
||||
|
||||
request, response = app.test_client.get("/composition_view")
|
||||
assert response.status == 200
|
||||
assert response.text == "OK"
|
||||
|
||||
request, response = app.test_client.post("/composition_view", data=data)
|
||||
assert response.status == 200
|
||||
assert response.text == data
|
||||
|
||||
|
||||
def test_request_stream(app):
|
||||
"""test for complex application"""
|
||||
bp = Blueprint("test_blueprint_request_stream")
|
||||
@@ -510,14 +483,8 @@ def test_request_stream(app):
|
||||
|
||||
app.add_route(SimpleView.as_view(), "/method_view")
|
||||
|
||||
view = CompositionView()
|
||||
view.add(["GET"], get_handler)
|
||||
view.add(["POST"], post_handler, stream=True)
|
||||
|
||||
app.blueprint(bp)
|
||||
|
||||
app.add_route(view, "/composition_view")
|
||||
|
||||
request, response = app.test_client.get("/method_view")
|
||||
assert response.status == 200
|
||||
assert response.text == "OK"
|
||||
@@ -526,14 +493,6 @@ def test_request_stream(app):
|
||||
assert response.status == 200
|
||||
assert response.text == data
|
||||
|
||||
request, response = app.test_client.get("/composition_view")
|
||||
assert response.status == 200
|
||||
assert response.text == "OK"
|
||||
|
||||
request, response = app.test_client.post("/composition_view", data=data)
|
||||
assert response.status == 200
|
||||
assert response.text == data
|
||||
|
||||
request, response = app.test_client.get("/get")
|
||||
assert response.status == 200
|
||||
assert response.text == "OK"
|
||||
|
||||
Reference in New Issue
Block a user