generated from ocadotechnology/codeforlife-template-backend
-
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.
- Loading branch information
1 parent
a8ff363
commit 0af7c1b
Showing
2 changed files
with
26 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,62 +15,50 @@ | |
class TestSchoolViewSet(ModelViewSetTestCase[School]): | ||
basename = "school" | ||
model_view_set_class = SchoolViewSet | ||
fixtures = ["non_school_teacher"] | ||
fixtures = ["non_school_teacher", "school_1"] | ||
|
||
def test_get_permissions__bulk(self): | ||
""" | ||
No one is allowed to perform bulk actions. | ||
""" | ||
"""No one is allowed to perform bulk actions.""" | ||
|
||
self.assert_get_permissions( | ||
permissions=[AllowNone()], | ||
action="bulk", | ||
) | ||
|
||
def test_get_permissions__list(self): | ||
""" | ||
No one is allowed to list schools. | ||
""" | ||
"""No one is allowed to list schools.""" | ||
|
||
self.assert_get_permissions( | ||
permissions=[AllowNone()], | ||
action="list", | ||
) | ||
|
||
def test_get_permissions__create(self): | ||
""" | ||
Only teachers not in a school can create a school. | ||
""" | ||
"""Only teachers not in a school can create a school.""" | ||
|
||
self.assert_get_permissions( | ||
permissions=[IsTeacher(), NOT(InSchool())], | ||
action="create", | ||
) | ||
|
||
def test_get_permissions__update(self): | ||
""" | ||
Only admin-teachers in a school can update a school. | ||
""" | ||
"""Only admin-teachers in a school can update a school.""" | ||
|
||
self.assert_get_permissions( | ||
permissions=[IsTeacher(is_admin=True), InSchool()], | ||
action="update", | ||
) | ||
|
||
def test_get_permissions__retrieve(self): | ||
""" | ||
Anyone in a school can retrieve a school. | ||
""" | ||
"""Anyone in a school can retrieve a school.""" | ||
|
||
self.assert_get_permissions( | ||
permissions=[InSchool()], | ||
action="retrieve", | ||
) | ||
|
||
def test_create(self): | ||
""" | ||
Can successfully create a school. | ||
""" | ||
"""Can successfully create a school.""" | ||
|
||
self.client.login_non_school_teacher( | ||
email="[email protected]", | ||
|
@@ -85,3 +73,21 @@ def test_create(self): | |
"country": "GB", | ||
}, | ||
) | ||
|
||
def test_partial_update(self): | ||
"""Can successfully update a school.""" | ||
|
||
user = self.client.login_school_teacher( | ||
is_admin=True, | ||
email="[email protected]", | ||
password="password", | ||
) | ||
|
||
self.client.partial_update( | ||
user.teacher.school, | ||
{ | ||
"name": "NewSchoolName", | ||
"uk_county": "Surrey", | ||
"country": "GB", | ||
}, | ||
) |
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