-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to test url in Blueprint? #3
Comments
You can just test it like normal url, eg. # module.py
from sanic import Sanic, Blueprint
from sanic.response import json
app = Sanic()
bp = Blueprint("test_blueprints", url_prefix="/blueprint")
@app.route("/")
async def test(request):
return json({"hello": "world"})
@bp.route("/bp")
async def test_blueprints(request):
return json({"foo": "bar"})
app.blueprint(bp) Then, # test.py
async def test_sanic_route(test_cli):
resp = await test_cli.get('/')
assert resp.status == 200
assert (await resp.json()) == {"hello": "world"}
async def test_sanic_blueprint(test_cli):
resp = await test_cli.get('/blueprint/bp')
assert resp.status == 200
assert (await resp.json()) == {"foo": "bar"} |
of course, you have to define BTW, |
@yunstanford , thank you very much. It works! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: