Exemple #1
0
    def test_mock_provider_exception(self, _, get_attempt_mock, logger_mock):
        """
        Test that the mock backend provider logs exception
        """
        provider = MockProctoringBackendProvider()

        attempt_code = 'test_code'

        get_attempt_mock.return_value = {
            'status': 'submitted',
            'attempt_code': attempt_code,
            'id': 1,
            'proctored_exam': {
                'course_id': '',
                'content_id': ''
            }
        }
        provider.register_exam_attempt(None, {'attempt_code': attempt_code})
        time.sleep(2)

        self.assertTrue(get_attempt_mock.called)

        log_format_string = (
            "BLOCKING ERROR: Can't find course info url for course_id=%s")
        logger_mock.assert_any_call(log_format_string, '')
Exemple #2
0
    def test_mock_provider(self):
        """
        Test that the mock backend provider does what we expect it to do.
        """
        provider = MockProctoringBackendProvider()
        attempt_code = "test_code"
        with patch('edx_proctoring.backends.mock.start_exam_callback') as exam_callback_mock:
            exam_callback_mock.return_value = '5'
            self.assertEqual(
                attempt_code,
                provider.register_exam_attempt(None, {'attempt_code': attempt_code})
            )
            # Wait for the thread to run.
            time.sleep(2)
            self.assertTrue(exam_callback_mock.called)

        self.assertEqual(
            "mockurl",
            provider.get_software_download_url()
        )
        self.assertIsNone(provider.start_exam_attempt(None, None))
        self.assertIsNone(provider.stop_exam_attempt(None, None))
        self.assertIsNone(provider.mark_erroneous_exam_attempt(None, None))
        self.assertIsNone(provider.on_review_callback(None, None))
        self.assertIsNone(provider.on_exam_saved(None))
Exemple #3
0
    def test_mock_provider(self):
        """
        Test that the mock backend provider does what we expect it to do.
        """
        provider = MockProctoringBackendProvider()
        attempt_code = "test_code"
        with patch('edx_proctoring.backends.mock.start_exam_callback') as exam_callback_mock:
            exam_callback_mock.return_value = '5'
            self.assertEqual(
                attempt_code,
                provider.register_exam_attempt(None, {'attempt_code': attempt_code})
            )
            # Wait for the thread to run.
            time.sleep(2)
            self.assertTrue(exam_callback_mock.called)

        self.assertEqual(
            "mockurl",
            provider.get_software_download_url()
        )
        self.assertIsNone(provider.start_exam_attempt(None, None))
        self.assertIsNone(provider.stop_exam_attempt(None, None))
        self.assertIsNone(provider.mark_erroneous_exam_attempt(None, None))
        self.assertIsNone(provider.on_review_callback(None, None))
        self.assertIsNone(provider.on_exam_saved(None))
Exemple #4
0
def setup_test_backends():
    """
    Sets up the backend entrypoints required for testing.
    """
    from django.apps import apps
    config = apps.get_app_config('edx_proctoring')
    from edx_proctoring.backends.tests.test_backend import TestBackendProvider
    from edx_proctoring.backends.null import NullBackendProvider
    from edx_proctoring.backends.mock import MockProctoringBackendProvider
    config.backends['test'] = TestBackendProvider()
    config.backends['null'] = NullBackendProvider()
    config.backends['mock'] = MockProctoringBackendProvider()