コード例 #1
0
def test_student_required__with_student(client, rf, student):
    req = rf.get("/test")
    req.user = student.student

    fct = student_required(lambda req: req.user)
    resp = fct(req)
    assert resp == student.student
コード例 #2
0
def test_student_required__with_anonymous_user(client, rf, user):
    req = rf.get("/test")
    req.user = AnonymousUser()

    fct = student_required(lambda req: req.user)
    resp = fct(req)
    assert resp.status_code == 403
    assert resp.template_name == "403.html"
コード例 #3
0
def test_student_required__with_teacher(client, rf, teacher):
    req = rf.get("/test")
    req.user = teacher.user

    fct = student_required(lambda req: req.user)
    resp = fct(req)
    assert resp.status_code == 403
    assert resp.template_name == "403.html"