Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-proctoring
Commits
8d23902c
Commit
8d23902c
authored
Jul 30, 2015
by
Afzal Wali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the tests and coverage.
parent
e65314ff
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
8 deletions
+33
-8
edx_proctoring/serializers.py
+1
-1
edx_proctoring/tests/test_api.py
+25
-6
edx_proctoring/tests/test_serializer.py
+5
-1
edx_proctoring/tests/test_views.py
+2
-0
No files found.
edx_proctoring/serializers.py
View file @
8d23902c
...
...
@@ -29,7 +29,7 @@ class ProctoredExamSerializer(serializers.ModelSerializer):
time_limit_mins
=
serializers
.
IntegerField
(
required
=
True
)
is_active
=
StrictBooleanField
(
required
=
True
)
is_practice_exam
=
StrictBooleanField
(
required
=
Fals
e
)
is_practice_exam
=
StrictBooleanField
(
required
=
Tru
e
)
is_proctored
=
StrictBooleanField
(
required
=
True
)
class
Meta
:
...
...
edx_proctoring/tests/test_api.py
View file @
8d23902c
...
...
@@ -160,6 +160,19 @@ class ProctoredExamApiTests(LoggedInTestCase):
allowed_time_limit_mins
=
10
)
def
_create_started_practice_exam_attempt
(
self
,
started_at
=
None
):
# pylint: disable=invalid-name
"""
Creates the ProctoredExamStudentAttempt object.
"""
return
ProctoredExamStudentAttempt
.
objects
.
create
(
proctored_exam_id
=
self
.
practice_exam_id
,
user_id
=
self
.
user_id
,
external_id
=
self
.
external_id
,
started_at
=
started_at
if
started_at
else
datetime
.
now
(
pytz
.
UTC
),
status
=
ProctoredExamStudentAttemptStatus
.
started
,
allowed_time_limit_mins
=
10
)
def
_add_allowance_for_user
(
self
):
"""
creates allowance for user.
...
...
@@ -202,11 +215,9 @@ class ProctoredExamApiTests(LoggedInTestCase):
update_practice_exam
=
ProctoredExam
.
objects
.
get
(
id
=
updated_practice_exam_id
)
self
.
assertEqual
(
update_practice_exam
.
exam_name
,
'Updated Exam Name'
)
self
.
assertEqual
(
update_practice_exam
.
time_limit_mins
,
30
)
self
.
assertEqual
(
update_practice_exam
.
time_limit_mins
,
31
)
self
.
assertEqual
(
update_practice_exam
.
course_id
,
'test_course'
)
self
.
assertEqual
(
update_practice_exam
.
content_id
,
'test_content_id'
)
self
.
assertEqual
(
update_practice_exam
.
content_id
,
'test_content_id_practice'
)
def
test_update_proctored_exam
(
self
):
"""
...
...
@@ -252,7 +263,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
assertEqual
(
proctored_exam
[
'exam_name'
],
self
.
exam_name
)
exams
=
get_all_exams_for_course
(
self
.
course_id
)
self
.
assertEqual
(
len
(
exams
),
3
)
self
.
assertEqual
(
len
(
exams
),
4
)
def
test_get_invalid_proctored_exam
(
self
):
"""
...
...
@@ -355,7 +366,15 @@ class ProctoredExamApiTests(LoggedInTestCase):
"""
proctored_exam_student_attempt
=
self
.
_create_unstarted_exam_attempt
()
with
self
.
assertRaises
(
StudentExamAttemptAlreadyExistsException
):
create_exam_attempt
(
proctored_exam_student_attempt
.
proctored_exam
,
self
.
user_id
)
create_exam_attempt
(
proctored_exam_student_attempt
.
proctored_exam
.
id
,
self
.
user_id
)
def
test_recreate_a_practice_exam_attempt
(
self
):
# pylint: disable=invalid-name
"""
Taking the practice exam several times should not cause an exception.
"""
practice_exam_student_attempt
=
self
.
_create_started_practice_exam_attempt
()
new_attempt_id
=
create_exam_attempt
(
practice_exam_student_attempt
.
proctored_exam
.
id
,
self
.
user_id
)
self
.
assertGreater
(
practice_exam_student_attempt
,
new_attempt_id
,
"New attempt not created."
)
def
test_get_exam_attempt
(
self
):
"""
...
...
edx_proctoring/tests/test_serializer.py
View file @
8d23902c
...
...
@@ -22,11 +22,15 @@ class TestProctoredExamSerializer(unittest.TestCase):
'time_limit_mins'
:
90
,
'external_id'
:
'123'
,
'is_proctored'
:
'bla'
,
'is_practice_exam'
:
'bla'
,
'is_active'
:
'f'
}
serializer
=
ProctoredExamSerializer
(
data
=
data
)
self
.
assertFalse
(
serializer
.
is_valid
())
self
.
assertDictEqual
(
{
'is_proctored'
:
[
u'This field is required.'
]},
serializer
.
errors
{
'is_proctored'
:
[
u'This field is required.'
],
'is_practice_exam'
:
[
u'This field is required.'
],
},
serializer
.
errors
)
edx_proctoring/tests/test_views.py
View file @
8d23902c
...
...
@@ -85,6 +85,7 @@ class ProctoredExamViewTests(LoggedInTestCase):
'time_limit_mins'
:
90
,
'external_id'
:
'123'
,
'is_proctored'
:
True
,
'is_practice_exam'
:
False
,
'is_active'
:
True
}
response
=
self
.
client
.
post
(
...
...
@@ -119,6 +120,7 @@ class ProctoredExamViewTests(LoggedInTestCase):
'time_limit_mins'
:
90
,
'external_id'
:
'123'
,
'is_proctored'
:
True
,
'is_practice_exam'
:
False
,
'is_active'
:
True
}
response
=
self
.
client
.
post
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment