-
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.
general tests and relocate login methods
- Loading branch information
Showing
4 changed files
with
74 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from ....tests import APITestCase | ||
|
||
|
||
class TestClassViewSet(APITestCase): | ||
pass # TODO |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import typing as t | ||
|
||
from rest_framework import status | ||
from rest_framework.permissions import IsAuthenticated | ||
|
||
from ....tests import APITestCase, APIClient | ||
from ...serializers import SchoolSerializer | ||
from ...views import SchoolViewSet | ||
from ...models import User, School, Teacher, Student, Class, UserProfile | ||
|
||
|
||
|
@@ -60,19 +62,19 @@ def setUp(self): | |
) | ||
|
||
def _login_teacher(self): | ||
return self.login_teacher( | ||
return self.client.login_teacher( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
||
def _login_student(self): | ||
return self.login_student( | ||
return self.client.login_student( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
||
def _login_indy_student(self): | ||
return self.login_indy_student( | ||
return self.client.login_indy_student( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
@@ -220,3 +222,23 @@ def test_list__student(self): | |
user = self._login_student() | ||
|
||
self._list_schools([user.student.class_field.teacher.school]) | ||
|
||
""" | ||
General tests that apply to all actions. | ||
""" | ||
|
||
def test_all__requires_authentication(self): | ||
""" | ||
User must be authenticated to call any endpoint. | ||
""" | ||
|
||
assert IsAuthenticated in SchoolViewSet.permission_classes | ||
|
||
def test_all__only_http_get(self): | ||
""" | ||
These model are read-only. | ||
""" | ||
|
||
assert [name.lower() for name in SchoolViewSet.http_method_names] == [ | ||
"get" | ||
] |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import typing as t | ||
|
||
from django.db.models.query import QuerySet | ||
from rest_framework import status | ||
from rest_framework.permissions import IsAuthenticated | ||
|
||
from ....tests import APITestCase, APIClient | ||
from ...serializers import UserSerializer | ||
from ...views import UserViewSet | ||
|
||
from ...models import User, School, Teacher, Student, Class, UserProfile | ||
|
||
|
||
|
@@ -61,19 +63,19 @@ def setUp(self): | |
) | ||
|
||
def _login_teacher(self): | ||
return self.login_teacher( | ||
return self.client.login_teacher( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
||
def _login_student(self): | ||
return self.login_student( | ||
return self.client.login_student( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
||
def _login_indy_student(self): | ||
return self.login_indy_student( | ||
return self.client.login_indy_student( | ||
email="[email protected]", | ||
password="Password1", | ||
) | ||
|
@@ -400,3 +402,23 @@ def test_list__indy_student(self): | |
user = self._login_indy_student() | ||
|
||
self._list_users([user]) | ||
|
||
""" | ||
General tests that apply to all actions. | ||
""" | ||
|
||
def test_all__requires_authentication(self): | ||
""" | ||
User must be authenticated to call any endpoint. | ||
""" | ||
|
||
assert IsAuthenticated in UserViewSet.permission_classes | ||
|
||
def test_all__only_http_get(self): | ||
""" | ||
These model are read-only. | ||
""" | ||
|
||
assert [name.lower() for name in UserViewSet.http_method_names] == [ | ||
"get" | ||
] |