Gitlab Community Edition Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Maximilian Michal
grady
Commits
103db3d5
There was a problem fetching the pipeline summary.
Commit
103db3d5
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Added more tests and some docstrings
parent
bd8946e1
Loading
Loading
1 merge request
!16
Backend tests
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/core/tests/test_access_rights.py
+42
-0
42 additions, 0 deletions
backend/core/tests/test_access_rights.py
backend/core/tests/test_tutor_api_endpoints.py
+7
-0
7 additions, 0 deletions
backend/core/tests/test_tutor_api_endpoints.py
with
49 additions
and
0 deletions
backend/core/tests/test_access_rights.py
0 → 100644
+
42
−
0
View file @
103db3d5
from
rest_framework.test
import
APITestCase
,
APIRequestFactory
,
force_authenticate
from
rest_framework
import
status
from
core.models
import
Reviewer
from
django.urls
import
reverse
from
core.views
import
StudentApiView
from
util.factories
import
GradyUserFactory
class
AccessRightsOfStudentAPIViewTests
(
APITestCase
):
"""
All tests that enshure that only students can see what students
should see belong here
"""
@classmethod
def
setUpTestData
(
cls
):
cls
.
factory
=
APIRequestFactory
()
cls
.
user_factory
=
GradyUserFactory
()
def
setUp
(
self
):
self
.
student
=
self
.
user_factory
.
make_student
()
self
.
tutor
=
self
.
user_factory
.
make_tutor
()
self
.
reviewer
=
self
.
user_factory
.
make_reviewer
()
self
.
request
=
self
.
factory
.
get
(
reverse
(
'
student-page
'
))
self
.
view
=
StudentApiView
.
as_view
()
def
test_unauthorized_access_denied
(
self
):
response
=
self
.
view
(
self
.
request
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_401_UNAUTHORIZED
)
def
test_tutor_has_no_access
(
self
):
force_authenticate
(
self
.
request
,
user
=
self
.
tutor
.
user
)
response
=
self
.
view
(
self
.
request
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_reviewer_has_no_access
(
self
):
force_authenticate
(
self
.
request
,
user
=
self
.
reviewer
.
user
)
response
=
self
.
view
(
self
.
request
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_student_is_authorized
(
self
):
force_authenticate
(
self
.
request
,
user
=
self
.
student
.
user
)
response
=
self
.
view
(
self
.
request
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
This diff is collapsed.
Click to expand it.
backend/core/tests/test_tutor_api_endpoints.py
0 → 100644
+
7
−
0
View file @
103db3d5
"""
Two api endpoints are currently planned
* GET /tutor/:id to retrive information about some tutor
* POST /tutor/:username/:email create a new tutor and email password
* GET /tutorlist list of all tutors with their scores
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment