Commit 1b194552 by Chris Dodge

make sure that we also time out when status is not just started

parent 0a429c11
...@@ -234,7 +234,7 @@ def _check_for_attempt_timeout(attempt): ...@@ -234,7 +234,7 @@ def _check_for_attempt_timeout(attempt):
has_started_exam = ( has_started_exam = (
attempt and attempt and
attempt.get('started_at') and attempt.get('started_at') and
attempt.get('status') == ProctoredExamStudentAttemptStatus.started ProctoredExamStudentAttemptStatus.is_incomplete_status(attempt.get('status'))
) )
if has_started_exam: if has_started_exam:
now_utc = datetime.now(pytz.UTC) now_utc = datetime.now(pytz.UTC)
......
...@@ -25,6 +25,7 @@ from edx_proctoring.api import ( ...@@ -25,6 +25,7 @@ from edx_proctoring.api import (
create_exam, create_exam,
create_exam_attempt, create_exam_attempt,
get_exam_attempt_by_id, get_exam_attempt_by_id,
update_attempt_status,
) )
from .utils import ( from .utils import (
...@@ -557,7 +558,13 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -557,7 +558,13 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
response_data = json.loads(response.content) response_data = json.loads(response.content)
self.assertEqual(response_data['status'], 'error') self.assertEqual(response_data['status'], 'error')
def test_attempt_callback_timeout(self): @ddt.data(
ProctoredExamStudentAttemptStatus.created,
ProctoredExamStudentAttemptStatus.ready_to_start,
ProctoredExamStudentAttemptStatus.started,
ProctoredExamStudentAttemptStatus.ready_to_submit
)
def test_attempt_callback_timeout(self, running_status):
""" """
Ensures that the polling from the client will cause the Ensures that the polling from the client will cause the
server to transition to timed_out if the user runs out of time server to transition to timed_out if the user runs out of time
...@@ -594,6 +601,9 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -594,6 +601,9 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self.assertEqual(response_data['status'], 'started') self.assertEqual(response_data['status'], 'started')
attempt_code = response_data['attempt_code'] attempt_code = response_data['attempt_code']
# now set status to what we want per DDT
update_attempt_status(proctored_exam.id, self.user.id, running_status)
# test the polling callback point # test the polling callback point
response = self.client.get( response = self.client.get(
reverse( reverse(
...@@ -603,7 +613,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -603,7 +613,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
response_data = json.loads(response.content) response_data = json.loads(response.content)
self.assertEqual(response_data['status'], 'started') self.assertEqual(response_data['status'], running_status)
# set time to be in future # set time to be in future
reset_time = datetime.now(pytz.UTC) + timedelta(minutes=180) reset_time = datetime.now(pytz.UTC) + timedelta(minutes=180)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment