def test_logged_in_non_student_required__with_teacher(rf, teacher): req = rf.get("/test") req.user = teacher.user fct = logged_in_non_student_required(lambda req: req.user) resp = fct(req) assert resp == teacher.user
def test_logged_in_non_student_required__with_regular_user(rf, user): req = rf.get("/test") req.user = user fct = logged_in_non_student_required(lambda req: req.user) resp = fct(req) assert resp == user
def test_logged_in_non_student_required__with_anonymous_user(rf): req = rf.get("/test") req.user = AnonymousUser() fct = logged_in_non_student_required(lambda req: req.user) resp = fct(req) assert resp.status_code == 403 assert resp.template_name == "403.html"
def test_logged_in_non_student_required__with_student(rf, student): req = rf.get("/test") req.user = student.student fct = logged_in_non_student_required(lambda req: req.user) resp = fct(req) assert resp.status_code == 403 assert resp.template_name == "403.html"