BOM-2268 : Add Pylint amnesty for Bulk Email (#26208)

* Add Amnest for Bulk Email
This commit is contained in:
M. Zulqarnain
2021-02-03 18:15:37 +05:00
committed by GitHub
parent c9c14ee6fc
commit 6f2d54d53b
15 changed files with 84 additions and 83 deletions

View File

@@ -7,7 +7,7 @@ from config_models.admin import ConfigurationModelAdmin
from django.contrib import admin
from lms.djangoapps.bulk_email.forms import CourseAuthorizationAdminForm, CourseEmailTemplateForm
from lms.djangoapps.bulk_email.models import BulkEmailFlag, CourseAuthorization, CourseEmail, CourseEmailTemplate, Optout
from lms.djangoapps.bulk_email.models import BulkEmailFlag, CourseAuthorization, CourseEmail, CourseEmailTemplate, Optout # lint-amnesty, pylint: disable=line-too-long
class CourseEmailAdmin(admin.ModelAdmin):

View File

@@ -1,3 +1,4 @@
# lint-amnesty, pylint: disable=missing-module-docstring
from django.apps import AppConfig

View File

@@ -7,11 +7,11 @@ import logging
import markupsafe
import six
from config_models.models import ConfigurationModel
from django.contrib.auth.models import User
from config_models.models import ConfigurationModel # lint-amnesty, pylint: disable=import-error
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from opaque_keys.edx.django.models import CourseKeyField
from opaque_keys.edx.django.models import CourseKeyField # lint-amnesty, pylint: disable=import-error
from six import text_type
from six.moves import zip
@@ -89,7 +89,7 @@ class Target(models.Model):
Returns a short display name
"""
if self.target_type == SEND_TO_COHORT:
return self.cohorttarget.short_display()
return self.cohorttarget.short_display() # lint-amnesty, pylint: disable=no-member
elif self.target_type == SEND_TO_TRACK:
return self.coursemodetarget.short_display()
else:
@@ -100,7 +100,7 @@ class Target(models.Model):
Returns a long display name
"""
if self.target_type == SEND_TO_COHORT:
return self.cohorttarget.long_display()
return self.cohorttarget.long_display() # lint-amnesty, pylint: disable=no-member
elif self.target_type == SEND_TO_TRACK:
return self.coursemodetarget.long_display()
else:
@@ -133,7 +133,7 @@ class Target(models.Model):
enrollment_qset.exclude(id__in=staff_instructor_qset)
)
elif self.target_type == SEND_TO_COHORT:
return self.cohorttarget.cohort.users.filter(id__in=enrollment_qset)
return self.cohorttarget.cohort.users.filter(id__in=enrollment_qset) # lint-amnesty, pylint: disable=no-member
elif self.target_type == SEND_TO_TRACK:
return use_read_replica_if_available(
User.objects.filter(
@@ -159,7 +159,7 @@ class CohortTarget(Target):
def __init__(self, *args, **kwargs):
kwargs['target_type'] = SEND_TO_COHORT
super(CohortTarget, self).__init__(*args, **kwargs)
super(CohortTarget, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
def __str__(self):
return self.short_display()
@@ -182,7 +182,7 @@ class CohortTarget(Target):
try:
cohort = get_cohort_by_name(name=cohort_name, course_key=course_id)
except CourseUserGroup.DoesNotExist:
raise ValueError(
raise ValueError( # lint-amnesty, pylint: disable=raise-missing-from
u"Cohort {cohort} does not exist in course {course_id}".format(
cohort=cohort_name,
course_id=course_id
@@ -205,7 +205,7 @@ class CourseModeTarget(Target):
def __init__(self, *args, **kwargs):
kwargs['target_type'] = SEND_TO_TRACK
super(CourseModeTarget, self).__init__(*args, **kwargs)
super(CourseModeTarget, self).__init__(*args, **kwargs) # lint-amnesty, pylint: disable=super-with-arguments
def __str__(self):
return self.short_display()
@@ -231,7 +231,7 @@ class CourseModeTarget(Target):
try:
validate_course_mode(six.text_type(course_id), mode_slug, include_expired=True)
except CourseModeNotFoundError:
raise ValueError(
raise ValueError( # lint-amnesty, pylint: disable=raise-missing-from
u"Track {track} does not exist in course {course_id}".format(
track=mode_slug,
course_id=course_id
@@ -275,7 +275,7 @@ class CourseEmail(Email):
# split target, to handle cohort:cohort_name and track:mode_slug
target_split = target.split(':', 1)
# Ensure our desired target exists
if target_split[0] not in EMAIL_TARGETS:
if target_split[0] not in EMAIL_TARGETS: # lint-amnesty, pylint: disable=no-else-raise
fmt = u'Course email being sent to unrecognized target: "{target}" for "{course}", subject "{subject}"'
msg = fmt.format(target=target, course=course_id, subject=subject).encode('utf8')
raise ValueError(msg)

View File

@@ -8,7 +8,7 @@ from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.bulk_email.models import Optout
class CourseEmailOptout(Policy):
class CourseEmailOptout(Policy): # lint-amnesty, pylint: disable=missing-class-docstring
def check(self, message):
course_ids = message.context.get('course_ids')

View File

@@ -12,7 +12,7 @@ from .models import Optout
@receiver(USER_RETIRE_MAILINGS)
def force_optout_all(sender, **kwargs):
def force_optout_all(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument
"""
When a user is retired from all mailings this method will create an Optout
row for any courses they may be enrolled in.

View File

@@ -26,19 +26,19 @@ from boto.ses.exceptions import (
SESLocalAddressCharacterError,
SESMaxSendingRateExceededError
)
from celery import current_task, shared_task
from celery.exceptions import RetryTaskError
from celery.states import FAILURE, RETRY, SUCCESS
from django.conf import settings
from django.core.mail import EmailMultiAlternatives, get_connection
from django.core.mail.message import forbid_multi_line_headers
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from edx_django_utils.monitoring import set_code_owner_attribute
from markupsafe import escape
from six import text_type
from celery import current_task, shared_task # lint-amnesty, pylint: disable=import-error
from celery.exceptions import RetryTaskError # lint-amnesty, pylint: disable=import-error
from celery.states import FAILURE, RETRY, SUCCESS # lint-amnesty, pylint: disable=import-error
from django.conf import settings # lint-amnesty, pylint: disable=wrong-import-order
from django.core.mail import EmailMultiAlternatives, get_connection # lint-amnesty, pylint: disable=wrong-import-order
from django.core.mail.message import forbid_multi_line_headers # lint-amnesty, pylint: disable=wrong-import-order
from django.urls import reverse # lint-amnesty, pylint: disable=wrong-import-order
from django.utils import timezone # lint-amnesty, pylint: disable=wrong-import-order
from django.utils.translation import override as override_language # lint-amnesty, pylint: disable=wrong-import-order
from django.utils.translation import ugettext as _ # lint-amnesty, pylint: disable=wrong-import-order
from edx_django_utils.monitoring import set_code_owner_attribute # lint-amnesty, pylint: disable=wrong-import-order
from markupsafe import escape # lint-amnesty, pylint: disable=wrong-import-order
from six import text_type # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.branding.api import get_logo_url_for_email
from lms.djangoapps.bulk_email.models import CourseEmail, Optout
@@ -144,7 +144,7 @@ def perform_delegate_email_batches(entry_id, course_id, task_input, action_name)
# code that doesn't need the entry_id.
if course_id != entry.course_id:
format_msg = u"Course id conflict: explicit value %r does not match task value %r"
log.warning(u"Task %s: " + format_msg, task_id, course_id, entry.course_id)
log.warning(u"Task %s: " + format_msg, task_id, course_id, entry.course_id) # lint-amnesty, pylint: disable=logging-not-lazy
raise ValueError(format_msg % (course_id, entry.course_id))
# Fetch the CourseEmail.
@@ -172,7 +172,7 @@ def perform_delegate_email_batches(entry_id, course_id, task_input, action_name)
# Sanity check that course for email_obj matches that of the task referencing it.
if course_id != email_obj.course_id:
format_msg = u"Course id conflict: explicit value %r does not match email value %r"
log.warning(u"Task %s: " + format_msg, task_id, course_id, email_obj.course_id)
log.warning(u"Task %s: " + format_msg, task_id, course_id, email_obj.course_id) # lint-amnesty, pylint: disable=logging-not-lazy
raise ValueError(format_msg % (course_id, email_obj.course_id))
# Fetch the course object.
@@ -427,7 +427,7 @@ def _get_source_address(course_id, course_title, course_language, truncate=True)
return from_addr
def _send_course_email(entry_id, email_id, to_list, global_email_context, subtask_status):
def _send_course_email(entry_id, email_id, to_list, global_email_context, subtask_status): # lint-amnesty, pylint: disable=too-many-statements
"""
Performs the email sending task.
@@ -590,7 +590,7 @@ def _send_course_email(entry_id, email_id, to_list, global_email_context, subtas
total_recipients,
email
)
if exc.smtp_code >= 400 and exc.smtp_code < 500:
if exc.smtp_code >= 400 and exc.smtp_code < 500: # lint-amnesty, pylint: disable=no-else-raise
# This will cause the outer handler to catch the exception and retry the entire task.
raise exc
else:

View File

@@ -26,14 +26,14 @@ from xmodule.modulestore.tests.factories import CourseFactory
from lms.djangoapps.bulk_email.api import get_unsubscribed_link
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
"""
def setUp(self):
super(TestOptoutCourseEmails, self).setUp()
super(TestOptoutCourseEmails, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(run='testcourse1', display_name=course_title)
self.instructor = AdminFactory.create()
@@ -144,14 +144,14 @@ class TestOptoutCourseEmails(ModuleStoreTestCase):
self.assertIn(self.instructor.email, sent_addresses)
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestACEOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
"""
def setUp(self):
super(TestACEOptoutCourseEmails, self).setUp()
super(TestACEOptoutCourseEmails, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(run='testcourse1', display_name=course_title)
self.instructor = AdminFactory.create()
@@ -163,7 +163,7 @@ class TestACEOptoutCourseEmails(ModuleStoreTestCase):
self._set_email_optout(False)
self.policy = CourseEmailOptout()
def _set_email_optout(self, opted_out):
def _set_email_optout(self, opted_out): # lint-amnesty, pylint: disable=missing-function-docstring
url = reverse('change_email_settings')
# This is a checkbox, so on the post of opting out (that is, an Un-check of the box),
# the Post that is sent will not contain 'receive_emails'

View File

@@ -22,20 +22,20 @@ from markupsafe import escape
from mock import Mock, patch
from ..models import BulkEmailFlag, Optout
from lms.djangoapps.bulk_email.tasks import _get_course_email_context, _get_source_address
from common.djangoapps.course_modes.models import CourseMode
from lms.djangoapps.bulk_email.tasks import _get_course_email_context, _get_source_address # lint-amnesty, pylint: disable=wrong-import-order
from common.djangoapps.course_modes.models import CourseMode # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.courseware.tests.factories import InstructorFactory, StaffFactory
from lms.djangoapps.instructor_task.subtasks import update_subtask_status
from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort
from openedx.core.djangoapps.course_groups.models import CourseCohort
from openedx.core.djangoapps.enrollments.api import update_enrollment
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.roles import CourseStaffRole
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from lms.djangoapps.courseware.tests.factories import InstructorFactory, StaffFactory # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.subtasks import update_subtask_status # lint-amnesty, pylint: disable=wrong-import-order
from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort # lint-amnesty, pylint: disable=wrong-import-order
from openedx.core.djangoapps.course_groups.models import CourseCohort # lint-amnesty, pylint: disable=wrong-import-order
from openedx.core.djangoapps.enrollments.api import update_enrollment # lint-amnesty, pylint: disable=wrong-import-order
from common.djangoapps.student.models import CourseEnrollment # lint-amnesty, pylint: disable=wrong-import-order
from common.djangoapps.student.roles import CourseStaffRole # lint-amnesty, pylint: disable=wrong-import-order
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
STAFF_COUNT = 3
STUDENT_COUNT = 10
@@ -113,7 +113,7 @@ class EmailSendFromDashboardTestCase(SharedModuleStoreTestCase):
)
def setUp(self):
super(EmailSendFromDashboardTestCase, self).setUp()
super(EmailSendFromDashboardTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=False)
self.create_staff_and_instructor()
self.create_students()
@@ -134,7 +134,7 @@ class EmailSendFromDashboardTestCase(SharedModuleStoreTestCase):
}
def tearDown(self):
super(EmailSendFromDashboardTestCase, self).tearDown()
super(EmailSendFromDashboardTestCase, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
BulkEmailFlag.objects.all().delete()
@@ -229,7 +229,7 @@ class LocalizedFromAddressCourseLangTestCase(SendEmailWithMockedUgettextMixin, E
self.assertRegex(message.from_email, 'AR .* Course Staff')
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase):
"""
Tests email sending with mocked html_to_text.
@@ -249,7 +249,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
# We should get back a HttpResponseForbidden (status code 403)
self.assertContains(response, "Email is not enabled for this course.", status_code=403)
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
def test_send_to_self(self):
"""
Make sure email send to myself goes to myself.

View File

@@ -38,11 +38,11 @@ from xmodule.modulestore.tests.factories import CourseFactory
class EmailTestException(Exception):
"""Mock exception for email testing."""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass
@ddt.ddt
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestEmailErrors(ModuleStoreTestCase):
"""
Test that errors from sending email are handled properly.
@@ -51,7 +51,7 @@ class TestEmailErrors(ModuleStoreTestCase):
ENABLED_CACHES = ['default', 'mongo_metadata_inheritance', 'loc_cache']
def setUp(self):
super(TestEmailErrors, self).setUp()
super(TestEmailErrors, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
self.instructor = AdminFactory.create()

View File

@@ -18,13 +18,13 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase):
"""Test the CourseAuthorizationAdminForm form for Mongo-backed courses."""
def setUp(self):
super(CourseAuthorizationFormTest, self).setUp()
super(CourseAuthorizationFormTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=True)
def tearDown(self):
super(CourseAuthorizationFormTest, self).tearDown()
super(CourseAuthorizationFormTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
BulkEmailFlag.objects.all().delete()
def test_authorize_mongo_course(self):

View File

@@ -31,7 +31,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@ddt.ddt
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class CourseEmailTest(ModuleStoreTestCase):
"""Test the CourseEmail model."""
@@ -148,7 +148,7 @@ class CourseEmailTest(ModuleStoreTestCase):
self.assertEqual(target.long_display(), 'Cohort: test cohort')
class OptoutTest(TestCase):
class OptoutTest(TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
def test_is_user_opted_out_for_course(self):
user = UserFactory.create()
course_id = CourseKey.from_string('abc/123/doremi')
@@ -175,7 +175,7 @@ class CourseEmailTemplateTest(TestCase):
"""Test the CourseEmailTemplate model."""
def setUp(self):
super(CourseEmailTemplateTest, self).setUp()
super(CourseEmailTemplateTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
# load initial content (since we don't run migrations as part of tests):
call_command("loaddata", "course_email_template.json")
@@ -274,7 +274,7 @@ class CourseAuthorizationTest(TestCase):
"""Test the CourseAuthorization model."""
def tearDown(self):
super(CourseAuthorizationTest, self).tearDown()
super(CourseAuthorizationTest, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
BulkEmailFlag.objects.all().delete()
def test_creation_auth_on(self):

View File

@@ -18,14 +18,14 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestOptoutCourseEmailsBySignal(ModuleStoreTestCase):
"""
Tests that the force_optout_all signal receiver opts the user out of course emails
"""
def setUp(self):
super(TestOptoutCourseEmailsBySignal, self).setUp()
super(TestOptoutCourseEmailsBySignal, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.course = CourseFactory.create(run='testcourse1', display_name="Test Course Title")
self.instructor = AdminFactory.create()
self.student = UserFactory.create()

View File

@@ -33,18 +33,18 @@ from opaque_keys.edx.locator import CourseLocator
from six.moves import range
from ..models import SEND_TO_LEARNERS, SEND_TO_MYSELF, SEND_TO_STAFF, CourseEmail, Optout
from lms.djangoapps.bulk_email.tasks import _get_course_email_context
from lms.djangoapps.instructor_task.models import InstructorTask
from lms.djangoapps.instructor_task.subtasks import SubtaskStatus, update_subtask_status
from lms.djangoapps.instructor_task.tasks import send_bulk_course_email
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskCourseTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from lms.djangoapps.bulk_email.tasks import _get_course_email_context # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.models import InstructorTask # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.subtasks import SubtaskStatus, update_subtask_status # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.tasks import send_bulk_course_email # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskCourseTestCase # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
class TestTaskFailure(Exception):
"""Dummy exception used for unit tests."""
pass
pass # lint-amnesty, pylint: disable=unnecessary-pass
def my_update_subtask_status(entry_id, current_task_id, new_subtask_status):
@@ -75,12 +75,12 @@ def my_update_subtask_status(entry_id, current_task_id, new_subtask_status):
update_subtask_status(entry_id, current_task_id, new_subtask_status)
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True)) # lint-amnesty, pylint: disable=line-too-long
class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
"""Tests instructor task that send bulk email."""
def setUp(self):
super(TestBulkEmailInstructorTask, self).setUp()
super(TestBulkEmailInstructorTask, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.initialize_course()
self.instructor = self.create_instructor('instructor')

View File

@@ -11,7 +11,7 @@ from django.urls import reverse
from lms.djangoapps.bulk_email.models import Optout
from lms.djangoapps.bulk_email.views import opt_out_email_updates
from six import text_type
from six import text_type # lint-amnesty, pylint: disable=wrong-import-order
from lms.djangoapps.discussion.notification_prefs.views import UsernameCipher
from openedx.core.lib.tests import attr
@@ -28,7 +28,7 @@ class OptOutEmailUpdatesViewTest(ModuleStoreTestCase):
Check the opt out email functionality.
"""
def setUp(self):
super(OptOutEmailUpdatesViewTest, self).setUp()
super(OptOutEmailUpdatesViewTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
self.user = UserFactory.create(username="testuser1", email='test@example.com')
self.course = CourseFactory.create(run='testcourse1', display_name='Test Course Title')
self.token = UsernameCipher.encrypt('testuser1')

View File

@@ -7,7 +7,7 @@ import logging
from six import text_type
from django.contrib.auth.models import User
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.http import Http404
from lms.djangoapps.bulk_email.models import Optout
@@ -18,8 +18,8 @@ from lms.djangoapps.discussion.notification_prefs.views import (
UsernameDecryptionException,
)
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError # lint-amnesty, pylint: disable=wrong-import-order
from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=wrong-import-order
log = logging.getLogger(__name__)
@@ -41,13 +41,13 @@ def opt_out_email_updates(request, token, course_id):
course_key = CourseKey.from_string(course_id)
course = get_course_by_id(course_key, depth=0)
except UnicodeDecodeError:
raise Http404("base64url")
raise Http404("base64url") # lint-amnesty, pylint: disable=raise-missing-from
except UsernameDecryptionException as exn:
raise Http404(text_type(exn))
raise Http404(text_type(exn)) # lint-amnesty, pylint: disable=raise-missing-from
except User.DoesNotExist:
raise Http404("username")
raise Http404("username") # lint-amnesty, pylint: disable=raise-missing-from
except InvalidKeyError:
raise Http404("course")
raise Http404("course") # lint-amnesty, pylint: disable=raise-missing-from
unsub_check = request.POST.get('unsubscribe', False)
context = {