Ejemplo n.º 1
0
def test_teacher_required__with_teacher(rf, teacher):
    req = rf.get("/test")
    req.user = teacher.user

    fct = teacher_required(lambda req, teacher: teacher)
    resp = fct(req)
    assert resp == teacher
Ejemplo n.º 2
0
def test_teacher_required__with_anonymous_user(rf):
    req = rf.get("/test")
    req.user = AnonymousUser()

    fct = teacher_required(lambda req, teacher: teacher)
    resp = fct(req)
    assert resp.status_code == 403
    assert resp.template_name == "403.html"
Ejemplo n.º 3
0
def test_teacher_required__with_student(rf, student):
    req = rf.get("/test")
    req.user = student.student

    fct = teacher_required(lambda req, teacher: teacher)
    resp = fct(req)
    assert resp.status_code == 403
    assert resp.template_name == "403.html"
Ejemplo n.º 4
0
def test_teacher_required__with_regular_user(rf, user):
    req = rf.get("/test")
    req.user = user

    fct = teacher_required(lambda req, teacher: teacher)
    resp = fct(req)
    assert resp.status_code == 403
    assert resp.template_name == "403.html"
Ejemplo n.º 5
0
 def setUp(self):
     self.req_factory = RequestFactory()
     self.teacher_required = teacher_required(lambda req: None)