Files
edx-platform/lms/djangoapps/verify_student/tests/test_tasks.py
Kyle McCormick d1a775d3cd Use full names for lms.djangoapps imports (#25401)
* Use full LMS imports paths in LMS settings and urls modules
* Use full LMS import paths in Studio settings and urls modules
* Import from lms.djangoapps.badges instead of badges
* Import from lms.djangoapps.branding instead of branding
* Import from lms.djangoapps.bulk_email instead of bulk_email
* Import from lms.djangoapps.bulk_enroll instead of bulk_enroll
* Import from lms.djangoapps.ccx instead of ccx
* Import from lms.djangoapps.course_api instead of course_api
* Import from lms.djangoapps.course_blocks instead of course_blocks
* Import from lms.djangoapps.course_wiki instead of course_wiki
* Import from lms.djangoapps.courseware instead of courseware
* Import from lms.djangoapps.dashboard instead of dashboard
* Import from lms.djangoapps.discussion import discussion
* Import from lms.djangoapps.email_marketing instead of email_marketing
* Import from lms.djangoapps.experiments instead of experiments
* Import from lms.djangoapps.gating instead of gating
* Import from lms.djangoapps.grades instead of grades
* Import from lms.djangoapps.instructor_analytics instead of instructor_analytics
* Import form lms.djangoapps.lms_xblock instead of lms_xblock
* Import from lms.djangoapps.lti_provider instead of lti_provider
* Import from lms.djangoapps.mobile_api instead of mobile_api
* Import from lms.djangoapps.rss_proxy instead of rss_proxy
* Import from lms.djangoapps.static_template_view instead of static_template_view
* Import from lms.djangoapps.survey instead of survey
* Import from lms.djangoapps.verify_student instead of verify_student
* Stop suppressing EdxPlatformDeprecatedImportWarnings
2020-11-04 08:48:33 -05:00

39 lines
1.7 KiB
Python

# Lots of patching to stub in our own settings, and HTTP posting
import ddt
import mock
from django.conf import settings
from mock import patch
from common.test.utils import MockS3BotoMixin
from lms.djangoapps.verify_student.tests import TestVerificationBase
from lms.djangoapps.verify_student.tests.test_models import FAKE_SETTINGS, mock_software_secure_post_unavailable
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
LOGGER_NAME = 'lms.djangoapps.verify_student.tasks'
@patch.dict(settings.VERIFY_STUDENT, FAKE_SETTINGS)
@ddt.ddt
class TestPhotoVerificationTasks(TestVerificationBase, MockS3BotoMixin, ModuleStoreTestCase):
@mock.patch('lms.djangoapps.verify_student.tasks.log')
def test_logs_for_retry_until_failure(self, mock_log):
retry_max_attempts = settings.SOFTWARE_SECURE_RETRY_MAX_ATTEMPTS
with mock.patch('lms.djangoapps.verify_student.tasks.requests.post', new=mock_software_secure_post_unavailable):
attempt = self.create_and_submit_attempt_for_user()
username = attempt.user.username
mock_log.error.assert_called_with(
'Software Secure submission failed for user %r, setting status to must_retry',
username,
exc_info=True
)
for current_attempt in range(retry_max_attempts):
mock_log.error.assert_any_call(
('Retrying sending request to Software Secure for user: %r, Receipt ID: %r '
'attempt#: %s of %s'),
username,
attempt.receipt_id,
current_attempt,
settings.SOFTWARE_SECURE_RETRY_MAX_ATTEMPTS,
)