Skip to content

Commit

Permalink
Actually test the right thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave St.Germain committed Nov 29, 2018
1 parent d3ae384 commit 19add1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
6 changes: 3 additions & 3 deletions edx_proctoring/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def get_backend_provider(exam=None):
"""
backend_name = None
if exam:
if exam['backend']:
backend_name = exam['backend']
elif 'is_proctored' in exam and not exam['is_proctored']:
if 'is_proctored' in exam and not exam['is_proctored']:
# timed exams don't have a backend
return None
elif exam['backend']:
backend_name = exam['backend']
return apps.get_app_config('edx_proctoring').get_backend(name=backend_name)
11 changes: 11 additions & 0 deletions edx_proctoring/backends/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ def test_backend_choices(self):
]
self.assertEqual(choices, expected)

def test_no_backend_for_timed_exams(self):
"""
Timed exams should not return a backend, even if one has accidentally been set
"""
exam = {
'is_proctored': False,
'backend': 'test'
}
backend = get_backend_provider(exam)
self.assertIsNone(backend)

def test_invalid_configurations(self):
"""
Test that invalid backends throw the right exceptions
Expand Down
19 changes: 0 additions & 19 deletions edx_proctoring/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,25 +1654,6 @@ def test_status_summary_bad(self):

self.assertIsNone(summary)

@patch('edx_proctoring.backends.tests.test_backend.TestBackendProvider')
def test_update_exam_attempt_timed(self, mock_backend):
"""
Make sure that timed exams do not try to update status in the backend
"""
attempt = self._create_unstarted_exam_attempt(is_proctored=False)
update_attempt_status(
attempt.proctored_exam_id,
self.user.id,
ProctoredExamStudentAttemptStatus.started
)
mock_backend.start_exam_attempt.assert_not_called()
update_attempt_status(
attempt.proctored_exam_id,
self.user.id,
ProctoredExamStudentAttemptStatus.submitted
)
mock_backend.stop_exam_attempt.assert_not_called()

def test_update_exam_attempt(self):
"""
Make sure we restrict which fields we can update
Expand Down

0 comments on commit 19add1b

Please sign in to comment.