-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Allow requester indies to retrieve school
- Loading branch information
1 parent
1221729
commit b73f4aa
Showing
3 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,14 @@ | |
|
||
from ...permissions import OR, AllowNone | ||
from ...tests import ModelViewSetTestCase | ||
from ..models import School, SchoolTeacherUser, StudentUser, User | ||
from ..permissions import IsStudent, IsTeacher | ||
from ..models import ( | ||
IndependentUser, | ||
School, | ||
SchoolTeacherUser, | ||
StudentUser, | ||
User, | ||
) | ||
from ..permissions import IsIndependent, IsStudent, IsTeacher | ||
from ..views import SchoolViewSet | ||
|
||
RequestUser = User | ||
|
@@ -16,6 +22,7 @@ | |
class TestSchoolViewSet(ModelViewSetTestCase[RequestUser, School]): | ||
basename = "school" | ||
model_view_set_class = SchoolViewSet | ||
fixtures = ["school_1", "independent"] | ||
|
||
# test: get permissions | ||
|
||
|
@@ -29,7 +36,12 @@ def test_get_permissions__list(self): | |
def test_get_permissions__retrieve(self): | ||
"""Only student and school-teachers can retrieve a school.""" | ||
self.assert_get_permissions( | ||
permissions=[OR(IsStudent(), IsTeacher(in_school=True))], | ||
permissions=[ | ||
OR( | ||
OR(IsStudent(), IsTeacher(in_school=True)), | ||
IsIndependent(is_requesting_to_join_class=True), | ||
) | ||
], | ||
action="retrieve", | ||
) | ||
|
||
|
@@ -55,6 +67,27 @@ def test_get_queryset__student(self): | |
request=self.client.request_factory.get(user=user), | ||
) | ||
|
||
def test_get_queryset__independent(self): | ||
""" | ||
An independent-user can only target the school they are requesting | ||
to join. | ||
""" | ||
user = IndependentUser.objects.get(username="[email protected]") | ||
assert user | ||
|
||
# klass = Class.objects.first() | ||
# assert klass | ||
|
||
# user.student.pending_class_request = klass | ||
# user.student.save() | ||
|
||
# assert user.student.pending_class_request is not None | ||
|
||
self.assert_get_queryset( | ||
values=[user.student.pending_class_request.teacher.school], | ||
request=self.client.request_factory.get(user=user), | ||
) | ||
|
||
# test: actions | ||
|
||
def test_retrieve(self): | ||
|