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
beef0da2
Commit
beef0da2
authored
Jul 03, 2015
by
Afzal Wali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved coverage.
parent
4333ba90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
4 deletions
+97
-4
edx_proctoring/tests/test_api.py
+97
-4
No files found.
edx_proctoring/tests/test_api.py
View file @
beef0da2
...
@@ -14,8 +14,8 @@ from edx_proctoring.api import (
...
@@ -14,8 +14,8 @@ from edx_proctoring.api import (
stop_exam_attempt
,
stop_exam_attempt
,
get_active_exams_for_user
,
get_active_exams_for_user
,
get_exam_attempt
,
get_exam_attempt
,
create_exam_attempt
create_exam_attempt
,
)
get_student_view
)
from
edx_proctoring.exceptions
import
(
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
ProctoredExamAlreadyExists
,
ProctoredExamNotFoundException
,
ProctoredExamNotFoundException
,
...
@@ -75,7 +75,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -75,7 +75,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
external_id
=
self
.
external_id
external_id
=
self
.
external_id
)
)
def
_create_started_exam_attempt
(
self
):
def
_create_started_exam_attempt
(
self
,
started_at
=
None
):
"""
"""
Creates the ProctoredExamStudentAttempt object.
Creates the ProctoredExamStudentAttempt object.
"""
"""
...
@@ -83,7 +83,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -83,7 +83,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
proctored_exam_id
=
self
.
proctored_exam_id
,
proctored_exam_id
=
self
.
proctored_exam_id
,
user_id
=
self
.
user_id
,
user_id
=
self
.
user_id
,
external_id
=
self
.
external_id
,
external_id
=
self
.
external_id
,
started_at
=
datetime
.
now
(
pytz
.
UTC
)
started_at
=
started_at
if
started_at
else
datetime
.
now
(
pytz
.
UTC
)
)
)
def
_add_allowance_for_user
(
self
):
def
_add_allowance_for_user
(
self
):
...
@@ -295,3 +295,96 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -295,3 +295,96 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
assertEqual
(
len
(
student_active_exams
),
2
)
self
.
assertEqual
(
len
(
student_active_exams
),
2
)
self
.
assertEqual
(
len
(
student_active_exams
[
0
][
'allowances'
]),
2
)
self
.
assertEqual
(
len
(
student_active_exams
[
0
][
'allowances'
]),
2
)
self
.
assertEqual
(
len
(
student_active_exams
[
1
][
'allowances'
]),
0
)
self
.
assertEqual
(
len
(
student_active_exams
[
1
][
'allowances'
]),
0
)
def
test_get_student_view
(
self
):
"""
Test for get_student_view
"""
rendered_response
=
get_student_view
(
user_id
=
self
.
user_id
,
course_id
=
self
.
course_id
,
content_id
=
self
.
content_id
,
context
=
{
'is_proctored'
:
True
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
}
)
self
.
assertIn
(
'data-exam-id="
%
d"'
%
self
.
proctored_exam_id
,
rendered_response
)
self
.
assertIn
(
'Would you Like to take
%
s as Proctored Exam?'
%
self
.
exam_name
,
rendered_response
)
def
test_getstudentview_timedexam
(
self
):
"""
Test for get_student_view Timed exam which is not proctored.
"""
rendered_response
=
get_student_view
(
user_id
=
self
.
user_id
,
course_id
=
"abc"
,
content_id
=
self
.
content_id
,
context
=
{
'is_proctored'
:
False
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
}
)
self
.
assertNotIn
(
'data-exam-id="
%
d"'
%
self
.
proctored_exam_id
,
rendered_response
)
self
.
assertIn
(
'
%
s is a Timed Exam'
%
self
.
exam_name
,
rendered_response
)
self
.
assertNotIn
(
'Would you Like to take
%
s as Proctored Exam?'
%
self
.
exam_name
,
rendered_response
)
def
test_getstudentview_unstartedxm
(
self
):
"""
Test for get_student_view proctored exam which has not started yet.
"""
self
.
_create_unstarted_exam_attempt
()
rendered_response
=
get_student_view
(
user_id
=
self
.
user_id
,
course_id
=
self
.
course_id
,
content_id
=
self
.
content_id
,
context
=
{
'is_proctored'
:
True
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
}
)
self
.
assertIn
(
'you have chosen to take
%
s as a proctored exam'
%
self
.
exam_name
,
rendered_response
)
def
test_getstudentview_startedxam
(
self
):
"""
Test for get_student_view proctored exam which has started.
"""
self
.
_create_started_exam_attempt
()
get_student_view
(
user_id
=
self
.
user_id
,
course_id
=
self
.
course_id
,
content_id
=
self
.
content_id
,
context
=
{
'is_proctored'
:
True
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
}
)
# TODO Not getting anything in this case. Will have to implement the testcase later.
# TODO No condition set for finished exam in the student view. Will have to test later.
def
test_getstudentview_expiredxam
(
self
):
"""
Test for get_student_view proctored exam which has started.
"""
self
.
_create_started_exam_attempt
(
started_at
=
datetime
.
now
(
pytz
.
UTC
)
.
replace
(
year
=
2010
))
rendered_response
=
get_student_view
(
user_id
=
self
.
user_id
,
course_id
=
self
.
course_id
,
content_id
=
self
.
content_id
,
context
=
{
'is_proctored'
:
True
,
'display_name'
:
self
.
exam_name
,
'default_time_limit_mins'
:
90
}
)
self
.
assertIn
(
'you did not submit your exam before the time allotted expired'
,
rendered_response
)
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