Update copy blueprint tests
This commit is contained in:
parent
fb41b3e0b2
commit
4ebb773e1a
@ -6,6 +6,8 @@ from sanic.response import text
|
||||
|
||||
def test_bp_copy(app: Sanic):
|
||||
bp1 = Blueprint("test_bp1", version=1)
|
||||
bp1.ctx.test = 1
|
||||
assert hasattr(bp1.ctx, "test")
|
||||
|
||||
@bp1.route("/page")
|
||||
def handle_request(request):
|
||||
@ -13,15 +15,26 @@ def test_bp_copy(app: Sanic):
|
||||
|
||||
bp2 = bp1.copy(name="test_bp2", version=2)
|
||||
assert id(bp1) != id(bp2)
|
||||
assert bp1._apps == bp2._apps == set()
|
||||
assert not hasattr(bp2.ctx, "test")
|
||||
|
||||
app.blueprint(bp1)
|
||||
app.blueprint(bp2)
|
||||
|
||||
bp3 = bp1.copy(name="test_bp3", version=3, with_registration=True)
|
||||
assert id(bp1) != id(bp3)
|
||||
assert bp1._apps == bp3._apps and bp3._apps
|
||||
assert not hasattr(bp3.ctx, "test")
|
||||
|
||||
bp4 = bp1.copy(name="test_bp4", version=4, with_ctx=True)
|
||||
assert id(bp1) != id(bp4)
|
||||
assert bp4.ctx.test == 1
|
||||
|
||||
bp5 = bp1.copy(name="test_bp5", version=5, with_registration=False)
|
||||
assert id(bp2) != id(bp3)
|
||||
assert id(bp3) != id(bp4)
|
||||
assert id(bp4) != id(bp5)
|
||||
assert id(bp1) != id(bp5)
|
||||
assert not bp5._apps
|
||||
assert bp1._apps != set()
|
||||
|
||||
app.blueprint(bp5)
|
||||
|
||||
_, response = app.test_client.get("/v1/page")
|
||||
|
Loading…
x
Reference in New Issue
Block a user