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
aba42382
There was a problem fetching the pipeline summary.
Commit
aba42382
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
ExamListView implemented and tested
parent
6efab98a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Backend tests
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/core/tests/test_examlist.py
+32
-0
32 additions, 0 deletions
backend/core/tests/test_examlist.py
backend/core/urls.py
+2
-0
2 additions, 0 deletions
backend/core/urls.py
backend/core/views.py
+6
-2
6 additions, 2 deletions
backend/core/views.py
with
40 additions
and
2 deletions
backend/core/tests/test_examlist.py
0 → 100644
+
32
−
0
View file @
aba42382
"""
Tests that we can receive information about what exams where written
"""
from
django.urls
import
reverse
from
rest_framework
import
status
from
rest_framework.test
import
(
APIRequestFactory
,
APITestCase
,
force_authenticate
)
from
core.models
import
ExamType
from
core.views
import
ExamListView
from
util.factories
import
GradyUserFactory
NUMBER_OF_TUTORS
=
7
class
ExamListTest
(
APITestCase
):
@classmethod
def
setUpTestData
(
cls
):
cls
.
factory
=
APIRequestFactory
()
cls
.
user_factory
=
GradyUserFactory
()
def
setUp
(
self
):
self
.
request
=
self
.
factory
.
get
(
reverse
(
'
exam-list
'
))
force_authenticate
(
self
.
request
,
self
.
user_factory
.
make_student
().
user
)
self
.
view
=
ExamListView
.
as_view
()
self
.
response
=
self
.
view
(
self
.
request
)
def
test_can_access_when_authenticated
(
self
):
self
.
assertEqual
(
self
.
response
.
status_code
,
status
.
HTTP_200_OK
)
def
test_getting_all_available_exams
(
self
):
self
.
assertEqual
(
ExamType
.
objects
.
count
(),
len
(
self
.
response
.
data
))
This diff is collapsed.
Click to expand it.
backend/core/urls.py
+
2
−
0
View file @
aba42382
...
...
@@ -7,6 +7,8 @@ from core import views
urlpatterns
=
[
url
(
r
'
^api/student/$
'
,
views
.
StudentApiView
.
as_view
(),
name
=
'
student-page
'
),
url
(
r
'
^api/examlist/$
'
,
views
.
ExamListView
.
as_view
(),
name
=
'
exam-list
'
),
url
(
r
'
^api/tutor/$
'
,
views
.
TutorCreateView
.
as_view
(),
name
=
'
tutor-create
'
),
url
(
r
'
^api/tutorlist/$
'
,
views
.
TutorListApiView
.
as_view
(),
name
=
'
tutor-list
'
),
...
...
This diff is collapsed.
Click to expand it.
backend/core/views.py
+
6
−
2
View file @
aba42382
...
...
@@ -3,8 +3,8 @@ import logging
from
rest_framework
import
generics
from
core.permissions
import
IsStudent
,
IsReviewer
from
core.serializers
import
StudentSerializer
,
TutorSerializer
from
core.models
import
Tutor
from
core.serializers
import
StudentSerializer
,
TutorSerializer
,
ExamSerializer
from
core.models
import
Tutor
,
ExamType
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -30,3 +30,7 @@ class TutorCreateView(generics.CreateAPIView):
permission_classes
=
(
IsReviewer
,)
serializer_class
=
TutorSerializer
class
ExamListView
(
generics
.
ListAPIView
):
queryset
=
ExamType
.
objects
.
all
()
serializer_class
=
ExamSerializer
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