Skip to content

Commit

Permalink
new python package
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Feb 16, 2024
1 parent f7ef992 commit 2c6df75
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pypi"
# Before adding a new package, check it's not listed under [packages] at
# https://github.com/ocadotechnology/codeforlife-package-python/blob/{ref}/Pipfile
# Replace "{ref}" in the above URL with the ref set below.
codeforlife = {ref = "bulk_anon_students", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
codeforlife = {ref = "v0.13.6", git = "https://github.com/ocadotechnology/codeforlife-package-python.git"}
# TODO: check if we need the below packages
whitenoise = "==6.5.0"
django-pipeline = "==2.0.8"
Expand All @@ -34,7 +34,7 @@ google-cloud-container = "==2.3.0"
# Before adding a new package, check it's not listed under [dev-packages] at
# https://github.com/ocadotechnology/codeforlife-package-python/blob/{ref}/Pipfile
# Replace "{ref}" in the above URL with the ref set below.
codeforlife = {ref = "bulk_anon_students", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
codeforlife = {ref = "v0.13.6", git = "https://github.com/ocadotechnology/codeforlife-package-python.git", extras = ["dev"]}
# TODO: check if we need the below packages
django-selenium-clean = "==0.3.3"
django-test-migrations = "==1.2.0"
Expand Down
14 changes: 7 additions & 7 deletions backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 17 additions & 24 deletions backend/api/tests/views/test_klass.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,24 @@ class TestClassViewSet(ModelViewSetTestCase[Class]):
model_view_set_class = ClassViewSet
fixtures = ["school_1"]

def test_get_permissions__bulk(self):
"""
No one is allowed to perform bulk actions.
"""
# test: get permissions

def test_get_permissions__bulk(self):
"""No one is allowed to perform bulk actions."""
self.assert_get_permissions(
permissions=[AllowNone()],
action="bulk",
)

def test_get_permissions__create(self):
"""
Only a school-teacher can create a class.
"""

"""Only school-teachers can create a class."""
self.assert_get_permissions(
permissions=[IsTeacher(in_school=True)],
action="create",
)

def test_get_permissions__update(self):
"""
Only an admin- or class-teacher can update a class.
"""

"""Only admin-teachers or class-teachers can update a class."""
self.assert_get_permissions(
permissions=[
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True))
Expand All @@ -53,10 +46,7 @@ def test_get_permissions__update(self):
)

def test_get_permissions__destroy(self):
"""
Only an admin- or class-teacher can destroy a class.
"""

"""Only admin-teachers or class-teachers can destroy a class."""
self.assert_get_permissions(
permissions=[
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True))
Expand All @@ -65,22 +55,25 @@ def test_get_permissions__destroy(self):
)

def test_get_permissions__list(self):
"""
Only a school-teacher can list classes.
"""

"""Only admin-teachers and class-teachers can list classes."""
self.assert_get_permissions(
permissions=[IsTeacher(in_school=True)],
permissions=[
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True))
],
action="list",
)

def test_get_permissions__retrieve(self):
"""
Any school-user can retrieve a class.
Only students, admin-teachers or class-teachers can retrieve a class.
"""

self.assert_get_permissions(
permissions=[OR(IsStudent(), IsTeacher(in_school=True))],
permissions=[
OR(
IsStudent(),
OR(IsTeacher(is_admin=True), IsTeacher(in_class=True)),
)
],
action="retrieve",
)

Expand Down

0 comments on commit 2c6df75

Please sign in to comment.