Pylint amnesty in openedx plugin_api, profile_images and programs apps (#26377)
This commit is contained in:
@@ -16,7 +16,7 @@ from common.djangoapps.edxmako.shortcuts import is_any_marketing_link_set, is_ma
|
||||
log = logging.getLogger('plugin_api')
|
||||
|
||||
|
||||
class EdxFragmentView(FragmentView):
|
||||
class EdxFragmentView(FragmentView): # lint-amnesty, pylint: disable=abstract-method
|
||||
"""
|
||||
The base class of all Open edX fragment views.
|
||||
"""
|
||||
@@ -79,7 +79,7 @@ class EdxFragmentView(FragmentView):
|
||||
for js_file in self.js_dependencies():
|
||||
fragment.add_javascript_url(staticfiles_storage.url(js_file))
|
||||
|
||||
def create_base_standalone_context(self, request, fragment, **kwargs):
|
||||
def create_base_standalone_context(self, request, fragment, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""
|
||||
Creates the base context for rendering a fragment as a standalone page.
|
||||
"""
|
||||
@@ -111,7 +111,7 @@ class EdxFragmentView(FragmentView):
|
||||
'is_marketing_link_set': is_marketing_link_set,
|
||||
})
|
||||
|
||||
def standalone_page_title(self, request, fragment, **kwargs):
|
||||
def standalone_page_title(self, request, fragment, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""
|
||||
Returns the page title for the standalone page, or None if there is no title.
|
||||
"""
|
||||
|
||||
@@ -3,7 +3,7 @@ Constants used by django app plugins
|
||||
"""
|
||||
|
||||
# expose constants from edx-django-utils so plugins using these continue to work
|
||||
from edx_django_utils.plugins import (
|
||||
from edx_django_utils.plugins import ( # lint-amnesty, pylint: disable=unused-import
|
||||
PluginSettings, # pylint: disable=unused-import
|
||||
PluginURLs, # pylint: disable=unused-import
|
||||
PluginSignals, # pylint: disable=unused-import
|
||||
|
||||
@@ -94,7 +94,7 @@ def validate_uploaded_image(uploaded_file):
|
||||
# adapted from https://github.com/pmitros/ProfileXBlock
|
||||
# see also: http://en.wikipedia.org/wiki/Magic_number_%28programming%29
|
||||
|
||||
if uploaded_file.size > settings.PROFILE_IMAGE_MAX_BYTES:
|
||||
if uploaded_file.size > settings.PROFILE_IMAGE_MAX_BYTES: # lint-amnesty, pylint: disable=no-else-raise
|
||||
file_upload_too_large = _(
|
||||
u'The file must be smaller than {image_max_size} in size.'
|
||||
).format(
|
||||
@@ -227,7 +227,7 @@ def _get_valid_file_types():
|
||||
"""
|
||||
Return comma separated string of valid file types.
|
||||
"""
|
||||
return ', '.join([', '.join(IMAGE_TYPES[ft].extensions) for ft in IMAGE_TYPES.keys()])
|
||||
return ', '.join([', '.join(IMAGE_TYPES[ft].extensions) for ft in IMAGE_TYPES.keys()]) # lint-amnesty, pylint: disable=consider-iterating-dictionary
|
||||
|
||||
|
||||
def _user_friendly_size(size):
|
||||
|
||||
@@ -43,7 +43,7 @@ class ProfileImageEndpointMixin(UserSettingsEventTestMixin):
|
||||
_view_name = None
|
||||
|
||||
def setUp(self):
|
||||
super(ProfileImageEndpointMixin, self).setUp()
|
||||
super(ProfileImageEndpointMixin, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.user = UserFactory.create(password=TEST_PASSWORD)
|
||||
# Ensure that parental controls don't apply to this user
|
||||
self.user.profile.year_of_birth = 1980
|
||||
@@ -61,7 +61,7 @@ class ProfileImageEndpointMixin(UserSettingsEventTestMixin):
|
||||
self.reset_tracker()
|
||||
|
||||
def tearDown(self):
|
||||
super(ProfileImageEndpointMixin, self).tearDown()
|
||||
super(ProfileImageEndpointMixin, self).tearDown() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
for name in get_profile_image_names(self.user.username).values():
|
||||
self.storage.delete(name)
|
||||
|
||||
@@ -366,7 +366,7 @@ class ProfileImageViewDeleteTestCase(ProfileImageEndpointMixin, APITestCase):
|
||||
_view_name = "accounts_profile_image_api"
|
||||
|
||||
def setUp(self):
|
||||
super(ProfileImageViewDeleteTestCase, self).setUp()
|
||||
super(ProfileImageViewDeleteTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
with make_image_file() as image_file:
|
||||
create_profile_images(image_file, get_profile_image_names(self.user.username))
|
||||
self.check_images()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# pylint: disable=unicode-format-string
|
||||
# lint-amnesty, pylint: disable=bad-option-value, unicode-format-string
|
||||
"""
|
||||
Defines the URL routes for this app.
|
||||
|
||||
@@ -6,7 +6,7 @@ NOTE: These views are deprecated. These routes are superseded by
|
||||
``/api/user/v1/accounts/{username}/image``, found in
|
||||
``openedx.core.djangoapps.user_api.urls``.
|
||||
"""
|
||||
# pylint: enable=unicode-format-string
|
||||
# pylint: enable=unicode-format-string # lint-amnesty, pylint: disable=bad-option-value
|
||||
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""
|
||||
""" # lint-amnesty, pylint: disable=django-not-configured
|
||||
Platform support for Programs.
|
||||
|
||||
This package is a thin wrapper around interactions with the Programs service,
|
||||
@@ -10,7 +10,7 @@ this package should be kept small, thin, and stateless.
|
||||
"""
|
||||
default_app_config = 'openedx.core.djangoapps.programs.apps.ProgramsConfig'
|
||||
|
||||
from edx_toggles.toggles import LegacyWaffleSwitch, LegacyWaffleSwitchNamespace
|
||||
from edx_toggles.toggles import LegacyWaffleSwitch, LegacyWaffleSwitchNamespace # lint-amnesty, pylint: disable=wrong-import-position
|
||||
|
||||
PROGRAMS_WAFFLE_SWITCH_NAMESPACE = LegacyWaffleSwitchNamespace(name='programs')
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Python APIs exposed by the Programs app to other in-process apps.
|
||||
from .utils import is_user_enrolled_in_program_type as _is_user_enrolled_in_program_type
|
||||
|
||||
|
||||
def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes_only=False, enrollments=None, entitlements=None):
|
||||
def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes_only=False, enrollments=None, entitlements=None): # lint-amnesty, pylint: disable=line-too-long
|
||||
"""
|
||||
This method will look at the learners Enrollments and Entitlements to determine
|
||||
if a learner is enrolled in a Program of the given type.
|
||||
|
||||
@@ -14,4 +14,4 @@ class ProgramsConfig(AppConfig):
|
||||
|
||||
def ready(self):
|
||||
# noinspection PyUnresolvedReferences
|
||||
from . import signals, tasks # pylint: disable=unused-variable
|
||||
from . import signals, tasks # lint-amnesty, pylint: disable=unused-import, unused-variable
|
||||
|
||||
@@ -182,7 +182,7 @@ def handle_course_cert_revoked(sender, user, course_key, mode, status, **kwargs)
|
||||
|
||||
|
||||
@receiver(COURSE_CERT_DATE_CHANGE, dispatch_uid='course_certificate_date_change_handler')
|
||||
def handle_course_cert_date_change(sender, course_key, **kwargs):
|
||||
def handle_course_cert_date_change(sender, course_key, **kwargs): # lint-amnesty, pylint: disable=unused-argument
|
||||
"""
|
||||
If course is updated and the certificate_available_date is changed,
|
||||
schedule a celery task to update visible_date for all certificates
|
||||
|
||||
@@ -7,7 +7,7 @@ from celery import task
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
|
||||
from django.contrib.sites.models import Site
|
||||
from edx_django_utils.monitoring import set_code_owner_attribute
|
||||
from edx_rest_api_client import exceptions
|
||||
@@ -123,7 +123,7 @@ def award_program_certificate(client, username, program_uuid, visible_date):
|
||||
|
||||
@task(bind=True, ignore_result=True)
|
||||
@set_code_owner_attribute
|
||||
def award_program_certificates(self, username):
|
||||
def award_program_certificates(self, username): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
This task is designed to be called whenever a student's completion status
|
||||
changes with respect to one or more courses (primarily, when a course
|
||||
@@ -225,7 +225,7 @@ def award_program_certificates(self, username):
|
||||
# client handles all 4XX errors the same way. In the future,
|
||||
# we may want to fork slumber, add 429 handling, and use that
|
||||
# in edx_rest_api_client.
|
||||
if exc.response.status_code == 429: # pylint: disable=no-member
|
||||
if exc.response.status_code == 429: # lint-amnesty, pylint: disable=no-else-raise, no-member
|
||||
rate_limit_countdown = 60
|
||||
LOGGER.info(
|
||||
u"""Rate limited. Retrying task to award certificates to user {username} in {countdown}
|
||||
|
||||
@@ -42,7 +42,7 @@ class BackpopulateProgramCredentialsTests(CatalogIntegrationMixin, CredentialsAp
|
||||
SAME_COURSE = 'same_course'
|
||||
|
||||
def setUp(self):
|
||||
super(BackpopulateProgramCredentialsTests, self).setUp()
|
||||
super(BackpopulateProgramCredentialsTests, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.alice = UserFactory()
|
||||
self.bob = UserFactory()
|
||||
|
||||
@@ -101,7 +101,7 @@ class CertChangedReceiverTest(TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(CertChangedReceiverTest, self).setUp()
|
||||
super(CertChangedReceiverTest, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.user = UserFactory.create(username=TEST_USERNAME)
|
||||
|
||||
@property
|
||||
|
||||
@@ -125,7 +125,7 @@ class AwardProgramCertificatesTestCase(CatalogIntegrationMixin, CredentialsApiCo
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(AwardProgramCertificatesTestCase, self).setUp()
|
||||
super(AwardProgramCertificatesTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
self.create_credentials_config()
|
||||
self.student = UserFactory.create(username='test-student')
|
||||
self.site = SiteFactory()
|
||||
@@ -431,7 +431,7 @@ class PostCourseCertificateTestCase(TestCase):
|
||||
Test the award_program_certificate function
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
def setUp(self): # lint-amnesty, pylint: disable=super-method-not-called
|
||||
self.student = UserFactory.create(username='test-student')
|
||||
self.course = CourseOverviewFactory.create(
|
||||
self_paced=True # Any option to allow the certificate to be viewable for the course
|
||||
@@ -487,7 +487,7 @@ class AwardCourseCertificatesTestCase(CredentialsApiConfigMixin, TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(AwardCourseCertificatesTestCase, self).setUp()
|
||||
super(AwardCourseCertificatesTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.available_date = datetime.now(pytz.UTC) + timedelta(days=1)
|
||||
self.course = CourseOverviewFactory.create(
|
||||
@@ -638,7 +638,7 @@ class RevokeProgramCertificatesTestCase(CatalogIntegrationMixin, CredentialsApiC
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(RevokeProgramCertificatesTestCase, self).setUp()
|
||||
super(RevokeProgramCertificatesTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.student = UserFactory.create(username='test-student')
|
||||
self.course_key = 'course-v1:testX+test101+2T2020'
|
||||
|
||||
@@ -27,7 +27,7 @@ from lms.djangoapps.certificates.api import MODES
|
||||
from lms.djangoapps.certificates.tests.factories import GeneratedCertificateFactory
|
||||
from lms.djangoapps.commerce.tests.test_utils import update_commerce_config
|
||||
from lms.djangoapps.commerce.utils import EcommerceService
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.keys import CourseKey # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from openedx.core.djangoapps.catalog.tests.factories import (
|
||||
CourseFactory,
|
||||
CourseRunFactory,
|
||||
@@ -69,7 +69,7 @@ class TestProgramProgressMeter(TestCase):
|
||||
"""Tests of the program progress utility class."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramProgressMeter, self).setUp()
|
||||
super(TestProgramProgressMeter, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory()
|
||||
self.site = SiteFactory()
|
||||
@@ -700,7 +700,7 @@ class TestProgramProgressMeter(TestCase):
|
||||
self._create_enrollments(course_run_key)
|
||||
meter = ProgramProgressMeter(self.site, self.user)
|
||||
mock_completed_course_runs.return_value = [{'course_run_id': course_run_key, 'type': CourseMode.VERIFIED}]
|
||||
self.assertEqual(meter._is_course_complete(course), True)
|
||||
self.assertEqual(meter._is_course_complete(course), True) # lint-amnesty, pylint: disable=protected-access
|
||||
|
||||
def test_detail_url_for_mobile_only(self, mock_get_programs):
|
||||
"""
|
||||
@@ -775,7 +775,7 @@ class TestProgramDataExtender(ModuleStoreTestCase):
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramDataExtender, self).setUp()
|
||||
super(TestProgramDataExtender, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.course = ModuleStoreCourseFactory()
|
||||
self.course.start = datetime.datetime.now(utc) - datetime.timedelta(days=1)
|
||||
@@ -1037,11 +1037,11 @@ class TestProgramDataExtender(ModuleStoreTestCase):
|
||||
- program has a course with more than one published course run
|
||||
"""
|
||||
course_run_1 = CourseRunFactory(
|
||||
key=str(ModuleStoreCourseFactory().id),
|
||||
key=str(ModuleStoreCourseFactory().id), # lint-amnesty, pylint: disable=no-member
|
||||
status='published'
|
||||
)
|
||||
course_run_2 = CourseRunFactory(
|
||||
key=str(ModuleStoreCourseFactory().id),
|
||||
key=str(ModuleStoreCourseFactory().id), # lint-amnesty, pylint: disable=no-member
|
||||
status='published'
|
||||
)
|
||||
course = CourseFactory(course_runs=[course_run_1, course_run_2], entitlements=[])
|
||||
@@ -1049,14 +1049,14 @@ class TestProgramDataExtender(ModuleStoreTestCase):
|
||||
courses=[
|
||||
CourseFactory(course_runs=[
|
||||
CourseRunFactory(
|
||||
key=str(ModuleStoreCourseFactory().id),
|
||||
key=str(ModuleStoreCourseFactory().id), # lint-amnesty, pylint: disable=no-member
|
||||
status='published'
|
||||
)
|
||||
]),
|
||||
course,
|
||||
CourseFactory(course_runs=[
|
||||
CourseRunFactory(
|
||||
key=str(ModuleStoreCourseFactory().id),
|
||||
key=str(ModuleStoreCourseFactory().id), # lint-amnesty, pylint: disable=no-member
|
||||
status='published'
|
||||
)
|
||||
])
|
||||
@@ -1247,7 +1247,7 @@ class TestGetCertificates(TestCase):
|
||||
Tests of the function used to get certificates associated with a program.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestGetCertificates, self).setUp()
|
||||
super(TestGetCertificates, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
self.user = UserFactory()
|
||||
self.program = ProgramFactory()
|
||||
@@ -1258,7 +1258,7 @@ class TestGetCertificates(TestCase):
|
||||
# Give all course runs a certificate URL, but only expect one to come
|
||||
# back. This verifies the break in the function under test that ensures
|
||||
# only one certificate per course comes back.
|
||||
for index, course_run in enumerate(course['course_runs']):
|
||||
for index, course_run in enumerate(course['course_runs']): # lint-amnesty, pylint: disable=unused-variable
|
||||
course_run['certificate_url'] = self.course_certificate_url
|
||||
course_run['may_certify'] = True
|
||||
|
||||
@@ -1301,7 +1301,7 @@ class TestGetCertificates(TestCase):
|
||||
"""
|
||||
# make the first course have no certification, the second have no url...
|
||||
for course_index, course in enumerate(self.program['courses']):
|
||||
for index, course_run in enumerate(course['course_runs']):
|
||||
for index, course_run in enumerate(course['course_runs']): # lint-amnesty, pylint: disable=unused-variable
|
||||
if course_index == 0:
|
||||
course_run['may_certify'] = False
|
||||
elif course_index == 1:
|
||||
@@ -1366,7 +1366,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestProgramMarketingDataExtender, self).setUp()
|
||||
super(TestProgramMarketingDataExtender, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Ensure the E-Commerce service user exists
|
||||
UserFactory(username=settings.ECOMMERCE_SERVICE_WORKER_USERNAME, is_staff=True)
|
||||
@@ -1386,7 +1386,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
Returns:
|
||||
seat: seat for which the discount is applicable
|
||||
"""
|
||||
self.ecommerce_service = EcommerceService()
|
||||
self.ecommerce_service = EcommerceService() # lint-amnesty, pylint: disable=attribute-defined-outside-init
|
||||
seat = self.program['courses'][0]['course_runs'][0]['seats'][0]
|
||||
self.program['applicable_seat_types'] = [seat['type']]
|
||||
return seat
|
||||
@@ -1407,7 +1407,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
def test_instructors(self):
|
||||
data = ProgramMarketingDataExtender(self.program, self.user).extend()
|
||||
|
||||
self.program.update(self.instructors['instructors'])
|
||||
self.program.update(self.instructors['instructors']) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertEqual(data, self.program)
|
||||
|
||||
def test_course_pricing(self):
|
||||
@@ -1468,7 +1468,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
data = ProgramMarketingDataExtender(self.program, self.user).extend()
|
||||
self._update_discount_data(mock_discount_data)
|
||||
|
||||
self.assertEqual(httpretty.last_request().querystring.get('username')[0], self.user.username)
|
||||
self.assertEqual(httpretty.last_request().querystring.get('username')[0], self.user.username) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertEqual(
|
||||
data['skus'],
|
||||
[course['course_runs'][0]['seats'][0]['sku'] for course in self.program['courses']]
|
||||
@@ -1495,7 +1495,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
content_type='application/json'
|
||||
)
|
||||
ProgramMarketingDataExtender(self.program, self.user).extend()
|
||||
self.assertEqual(httpretty.last_request().querystring.get('is_anonymous')[0], u'True')
|
||||
self.assertEqual(httpretty.last_request().querystring.get('is_anonymous')[0], u'True') # lint-amnesty, pylint: disable=no-member
|
||||
|
||||
@httpretty.activate
|
||||
def test_fetching_program_discounted_price_as_anonymous_user(self):
|
||||
@@ -1520,7 +1520,7 @@ class TestProgramMarketingDataExtender(ModuleStoreTestCase):
|
||||
data = ProgramMarketingDataExtender(self.program, user).extend()
|
||||
self._update_discount_data(mock_discount_data)
|
||||
|
||||
self.assertIsNotNone(httpretty.last_request().querystring.get('is_anonymous', None))
|
||||
self.assertIsNotNone(httpretty.last_request().querystring.get('is_anonymous', None)) # lint-amnesty, pylint: disable=no-member
|
||||
self.assertEqual(
|
||||
data['skus'],
|
||||
[course['course_runs'][0]['seats'][0]['sku'] for course in self.program['courses']]
|
||||
@@ -1603,12 +1603,12 @@ class TestProgramEnrollment(SharedModuleStoreTestCase):
|
||||
CourseEnrollmentFactory.create(user=self.user, course_id=self.course_run.id, mode=CourseMode.AUDIT)
|
||||
mock_get_programs_by_type.return_value = [self.program]
|
||||
self.assertFalse(
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True)
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True) # lint-amnesty, pylint: disable=line-too-long
|
||||
)
|
||||
|
||||
# NEW CODE HERE
|
||||
@mock.patch('openedx.core.djangoapps.programs.utils.get_paid_modes_for_course')
|
||||
def test_user_enrolled_in_paid_only_with_no_matching_paid_course_modes(self, mock_get_paid_modes_for_course, mock_get_programs_by_type):
|
||||
def test_user_enrolled_in_paid_only_with_no_matching_paid_course_modes(self, mock_get_paid_modes_for_course, mock_get_programs_by_type): # lint-amnesty, pylint: disable=line-too-long
|
||||
second_program = ProgramFactory(type=self.MICROBACHELORS)
|
||||
second_catalog_course_run = second_program['courses'][0]['course_runs'][0]
|
||||
second_course_key = CourseKey.from_string(second_catalog_course_run['key'])
|
||||
@@ -1624,19 +1624,19 @@ class TestProgramEnrollment(SharedModuleStoreTestCase):
|
||||
mock_get_programs_by_type.return_value = [self.program, second_program]
|
||||
|
||||
# While most of a programs courses would likely come with a paid mode, if the course in question is now expired,
|
||||
# then get_paid_modes_for_course would return an empty list. Even with no paid modes, if we request paid modes only
|
||||
# then get_paid_modes_for_course would return an empty list. Even with no paid modes, if we request paid modes only # lint-amnesty, pylint: disable=line-too-long
|
||||
# we should return False
|
||||
mock_get_paid_modes_for_course.return_value = []
|
||||
# raise Exception((mock_get_programs_by_type, mock_get_paid_modes_for_course))
|
||||
self.assertFalse(
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True)
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True) # lint-amnesty, pylint: disable=line-too-long
|
||||
)
|
||||
|
||||
# We should continue to return false even if they do contain paid modes
|
||||
Mode = namedtuple('Mode', ['slug'])
|
||||
Mode = namedtuple('Mode', ['slug']) # lint-amnesty, pylint: disable=unused-variable
|
||||
# mock_get_paid_modes_for_course.return_value = [Mode(CourseMode.VERIFIED)]
|
||||
self.assertFalse(
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True)
|
||||
is_user_enrolled_in_program_type(user=self.user, program_type_slug=self.MICROBACHELORS, paid_modes_only=True) # lint-amnesty, pylint: disable=line-too-long
|
||||
)
|
||||
|
||||
def test_user_with_entitlement_no_enrollment(self, mock_get_programs_by_type):
|
||||
|
||||
@@ -19,7 +19,7 @@ from django.utils.functional import cached_property
|
||||
from edx_rest_api_client.exceptions import SlumberBaseException
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from pytz import utc
|
||||
from requests.exceptions import ConnectionError, Timeout
|
||||
from requests.exceptions import ConnectionError, Timeout # lint-amnesty, pylint: disable=redefined-builtin
|
||||
from six.moves.urllib.parse import urljoin, urlparse, urlunparse # pylint: disable=import-error
|
||||
|
||||
from common.djangoapps.course_modes.api import get_paid_modes_for_course
|
||||
@@ -627,7 +627,7 @@ class ProgramDataExtender(object):
|
||||
|
||||
return courses_without_enrollments
|
||||
|
||||
def _collect_one_click_purchase_eligibility_data(self):
|
||||
def _collect_one_click_purchase_eligibility_data(self): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Extend the program data with data about learner's eligibility for one click purchase,
|
||||
discount data of the program and SKUs of seats that should be added to basket.
|
||||
@@ -641,7 +641,7 @@ class ProgramDataExtender(object):
|
||||
skus = []
|
||||
bundle_variant = 'full'
|
||||
|
||||
if is_learner_eligible_for_one_click_purchase:
|
||||
if is_learner_eligible_for_one_click_purchase: # lint-amnesty, pylint: disable=too-many-nested-blocks
|
||||
courses = self.data['courses']
|
||||
if not self.user.is_anonymous:
|
||||
courses = self._filter_out_courses_with_enrollments(courses)
|
||||
@@ -791,7 +791,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
|
||||
user (User): The user whose enrollments to inspect.
|
||||
"""
|
||||
def __init__(self, program_data, user):
|
||||
super(ProgramMarketingDataExtender, self).__init__(program_data, user)
|
||||
super(ProgramMarketingDataExtender, self).__init__(program_data, user) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
|
||||
# Aggregate list of instructors for the program keyed by name
|
||||
self.instructors = []
|
||||
@@ -843,7 +843,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
|
||||
|
||||
def extend(self):
|
||||
"""Execute extension handlers, returning the extended data."""
|
||||
self.data.update(super(ProgramMarketingDataExtender, self).extend())
|
||||
self.data.update(super(ProgramMarketingDataExtender, self).extend()) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
return self.data
|
||||
|
||||
@classmethod
|
||||
@@ -865,11 +865,11 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
|
||||
pages. The certificate URL is not needed when rendering
|
||||
the program marketing page.
|
||||
"""
|
||||
pass
|
||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||
|
||||
def _attach_course_run_upgrade_url(self, run_mode):
|
||||
if not self.user.is_anonymous:
|
||||
super(ProgramMarketingDataExtender, self)._attach_course_run_upgrade_url(run_mode)
|
||||
super(ProgramMarketingDataExtender, self)._attach_course_run_upgrade_url(run_mode) # lint-amnesty, pylint: disable=super-with-arguments
|
||||
else:
|
||||
run_mode['upgrade_url'] = None
|
||||
|
||||
@@ -902,7 +902,7 @@ class ProgramMarketingDataExtender(ProgramDataExtender):
|
||||
self.instructors.append(instructor)
|
||||
|
||||
|
||||
def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes_only=False, enrollments=None, entitlements=None):
|
||||
def is_user_enrolled_in_program_type(user, program_type_slug, paid_modes_only=False, enrollments=None, entitlements=None): # lint-amnesty, pylint: disable=line-too-long
|
||||
"""
|
||||
This method will look at the learners Enrollments and Entitlements to determine
|
||||
if a learner is enrolled in a Program of the given type.
|
||||
|
||||
Reference in New Issue
Block a user