Skip to content
Merged
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion cms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# This will make sure the app is always imported when Django starts so
# that shared_task will use this app, and also ensures that the celery
# singleton is always configured for the CMS.
from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position
from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position # noqa: F401
2 changes: 1 addition & 1 deletion cms/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# Set the default Django settings module for the 'celery' program
# and then instantiate the Celery singleton.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cms.envs.production')
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import
from openedx.core.lib.celery import APP # pylint: disable=wrong-import-position,unused-import # noqa: F401
2 changes: 1 addition & 1 deletion cms/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def pytest_configure(config):
logging.info("pytest did not register json_report correctly")


@pytest.fixture(autouse=True, scope='function')
@pytest.fixture(autouse=True, scope='function') # noqa: PT003
def _django_clear_site_cache():
"""
pytest-django uses this fixture to automatically clear the Site object
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/api/v1/serializers/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def to_internal_value(self, data):
try:
User.objects.get(username=member['user'])
except User.DoesNotExist:
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
_('Course team user does not exist')
)

Expand Down Expand Up @@ -171,7 +171,7 @@ def validate(self, attrs):
with store.default_store('split'):
new_course_run_key = store.make_course_key(course_run_key.org, number, run)
except InvalidKeyError:
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from
raise serializers.ValidationError( # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
'Invalid key supplied. Ensure there are no special characters in the Course Number.'
)
if store.has_course(new_course_run_key, ignore_case=True):
Expand Down
28 changes: 14 additions & 14 deletions cms/djangoapps/api/v1/tests/test_views/test_course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import datetime
from unittest.mock import patch # lint-amnesty, pylint: disable=unused-import
from unittest.mock import patch # lint-amnesty, pylint: disable=unused-import # noqa: F401

import ddt
import pytz
Expand Down Expand Up @@ -266,15 +266,15 @@ def test_create(self, pacing_type, expected_self_paced_value):
data = self.get_course_run_data(user, start, end, pacing_type, role)

response = self.client.post(self.list_url, data, format='json')
self.assertEqual(response.status_code, 201)
self.assertEqual(response.status_code, 201) # noqa: PT009

course_run_key = CourseKey.from_string(response.data['id'])
course_run = modulestore().get_course(course_run_key)
self.assertEqual(course_run.display_name, data['title'])
self.assertEqual(course_run.id.org, data['org'])
self.assertEqual(course_run.id.course, data['number'])
self.assertEqual(course_run.id.run, data['run'])
self.assertEqual(course_run.self_paced, expected_self_paced_value)
self.assertEqual(course_run.display_name, data['title']) # noqa: PT009
self.assertEqual(course_run.id.org, data['org']) # noqa: PT009
self.assertEqual(course_run.id.course, data['number']) # noqa: PT009
self.assertEqual(course_run.id.run, data['run']) # noqa: PT009
self.assertEqual(course_run.self_paced, expected_self_paced_value) # noqa: PT009
self.assert_course_run_schedule(course_run, start, end)
self.assert_access_role(course_run, user, role)
self.assert_course_access_role_count(course_run, 1)
Expand All @@ -290,8 +290,8 @@ def test_create_with_invalid_course_team(self):
data = self.get_course_run_data(user, start, end, 'self-paced')
data['team'] = [{'user': 'invalid-username'}]
response = self.client.post(self.list_url, data, format='json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.data.get('team'), ['Course team user does not exist'])
self.assertEqual(response.status_code, 400) # noqa: PT009
self.assertEqual(response.data.get('team'), ['Course team user does not exist']) # noqa: PT009

def test_images_upload(self):
# http://www.django-rest-framework.org/api-guide/parsers/#fileuploadparser
Expand Down Expand Up @@ -382,8 +382,8 @@ def test_rerun(self, pacing_type, expected_self_paced_value, number):
self.assert_access_role(course_run, user, role)
self.assert_course_access_role_count(course_run, 1)
course_orgs = get_course_organizations(course_run_key)
self.assertEqual(len(course_orgs), 1)
self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org) # lint-amnesty, pylint: disable=no-member
self.assertEqual(len(course_orgs), 1) # noqa: PT009
self.assertEqual(course_orgs[0]['short_name'], original_course_run.id.org) # lint-amnesty, pylint: disable=no-member # noqa: PT009

def test_rerun_duplicate_run(self):
course_run = ToyCourseFactory()
Expand Down Expand Up @@ -417,7 +417,7 @@ def test_clone_course(self):
}
response = self.client.post(url, data, format='json')
assert response.status_code == 201
self.assertEqual(response.data, {"message": "Course cloned successfully."})
self.assertEqual(response.data, {"message": "Course cloned successfully."}) # noqa: PT009

def test_clone_course_with_missing_source_id(self):
url = reverse('api:v1:course_run-clone')
Expand All @@ -426,7 +426,7 @@ def test_clone_course_with_missing_source_id(self):
}
response = self.client.post(url, data, format='json')
assert response.status_code == 400
self.assertEqual(response.data, {'source_course_id': ['This field is required.']})
self.assertEqual(response.data, {'source_course_id': ['This field is required.']}) # noqa: PT009

def test_clone_course_with_missing_dest_id(self):
url = reverse('api:v1:course_run-clone')
Expand All @@ -435,7 +435,7 @@ def test_clone_course_with_missing_dest_id(self):
}
response = self.client.post(url, data, format='json')
assert response.status_code == 400
self.assertEqual(response.data, {'destination_course_id': ['This field is required.']})
self.assertEqual(response.data, {'destination_course_id': ['This field is required.']}) # noqa: PT009

def test_clone_course_with_nonexistent_source_course(self):
url = reverse('api:v1:course_run-clone')
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/api/v1/views/course_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_object(self):
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field

assert lookup_url_kwarg in self.kwargs, (
'Expected view %s to be called with a URL keyword argument '
'Expected view %s to be called with a URL keyword argument ' # noqa: UP031
'named "%s". Fix your URL conf, or set the `.lookup_field` '
'attribute on the view correctly.' %
(self.__class__.__name__, lookup_url_kwarg)
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/cms_user_tasks/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def ready(self):
"""
Connect signal handlers.
"""
from . import signals # pylint: disable=unused-import
from . import signals # pylint: disable=unused-import # noqa: F401
34 changes: 17 additions & 17 deletions cms/djangoapps/cms_user_tasks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ def create_olx_validation_artifact(self):

def assert_msg_subject(self, msg):
"""Verify that msg subject is in expected format."""
subject = "{platform_name} {studio_name}: Task Status Update".format(
subject = "{platform_name} {studio_name}: Task Status Update".format( # noqa: UP032
platform_name=settings.PLATFORM_NAME, studio_name=settings.STUDIO_NAME
)
self.assertEqual(msg.subject, subject)
self.assertEqual(msg.subject, subject) # noqa: PT009

def assert_msg_body_fragments(self, msg, body_fragments):
"""Verify that email body contains expected fragments"""
for fragment in body_fragments:
self.assertIn(fragment, msg.body)
self.assertIn(fragment, msg.body) # noqa: PT009

def test_email_sent_with_site(self):
"""
Expand All @@ -201,7 +201,7 @@ def test_email_sent_with_site(self):
reverse('usertaskstatus-detail', args=[self.status.uuid])
]

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1) # noqa: PT009

msg = mail.outbox[0]

Expand All @@ -216,7 +216,7 @@ def test_email_not_sent_with_libary_import_task(self):
end_of_task_status.name = "bulk_migrate_from_modulestore"
user_task_stopped.send(sender=UserTaskStatus, status=end_of_task_status)

self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 0) # noqa: PT009

def test_email_not_sent_with_libary_content_update(self):
"""
Expand All @@ -229,7 +229,7 @@ def test_email_not_sent_with_libary_content_update(self):
end_of_task_status.name = "updating block-v1:course+type@library_content+block@uuid from library"
user_task_stopped.send(sender=UserTaskStatus, status=end_of_task_status)

self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 0) # noqa: PT009

def test_email_not_sent_with_legacy_libary_content_ref_update(self):
"""
Expand All @@ -239,7 +239,7 @@ def test_email_not_sent_with_legacy_libary_content_ref_update(self):
end_of_task_status.name = "Updating legacy library content blocks references of course-v1:UNIX+UN1+2025_T4"
user_task_stopped.send(sender=UserTaskStatus, status=end_of_task_status)

self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 0) # noqa: PT009

def test_email_sent_with_olx_validations_with_config_enabled(self):
"""
Expand All @@ -258,7 +258,7 @@ def test_email_sent_with_olx_validations_with_config_enabled(self):
user_task_stopped.send(sender=UserTaskStatus, status=self.status)
msg = mail.outbox[0]

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1) # noqa: PT009
self.assert_msg_subject(msg)
self.assert_msg_body_fragments(msg, body_fragments_with_validation)

Expand All @@ -277,8 +277,8 @@ def test_email_sent_with_olx_validations_with_default_config(self):
msg = mail.outbox[0]

# Verify olx validation is not enabled out of the box.
self.assertFalse(settings.FEATURES.get('ENABLE_COURSE_OLX_VALIDATION'))
self.assertEqual(len(mail.outbox), 1)
self.assertFalse(settings.FEATURES.get('ENABLE_COURSE_OLX_VALIDATION')) # noqa: PT009
self.assertEqual(len(mail.outbox), 1) # noqa: PT009
self.assert_msg_subject(msg)
self.assert_msg_body_fragments(msg, body_fragments)

Expand All @@ -298,11 +298,11 @@ def test_email_sent_with_olx_validations_with_bypass_flag(self):

user_task_stopped.send(sender=UserTaskStatus, status=self.status)

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1) # noqa: PT009
msg = mail.outbox[0]
self.assert_msg_subject(msg)
self.assert_msg_body_fragments(msg, body_fragments)
self.assertNotIn("Here are some validations we found with your course content.", msg.body)
self.assertNotIn("Here are some validations we found with your course content.", msg.body) # noqa: PT009

def test_email_not_sent_for_child(self):
"""
Expand All @@ -312,7 +312,7 @@ def test_email_not_sent_for_child(self):
user=self.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2',
total_steps=5, parent=self.status)
user_task_stopped.send(sender=UserTaskStatus, status=child_status)
self.assertEqual(len(mail.outbox), 0)
self.assertEqual(len(mail.outbox), 0) # noqa: PT009

def test_email_sent_without_site(self):
"""
Expand All @@ -325,7 +325,7 @@ def test_email_sent_without_site(self):
"Sign in to view the details of your task or download any files created."
]

self.assertEqual(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1) # noqa: PT009

msg = mail.outbox[0]
self.assert_msg_subject(msg)
Expand All @@ -342,7 +342,7 @@ def test_email_retries(self):

with mock.patch('cms.djangoapps.cms_user_tasks.tasks.send_task_complete_email.retry') as mock_retry:
user_task_stopped.send(sender=UserTaskStatus, status=self.status)
self.assertTrue(mock_retry.called)
self.assertTrue(mock_retry.called) # noqa: PT009

def test_queue_email_failure(self):
logger = logging.getLogger("cms.djangoapps.cms_user_tasks.signals")
Expand All @@ -354,5 +354,5 @@ def test_queue_email_failure(self):
{'error_response': 'error occurred'}, {'operation_name': 'test'}
)
user_task_stopped.send(sender=UserTaskStatus, status=self.status)
self.assertTrue(mock_delay.called)
self.assertEqual(hdlr.messages['error'][0], 'Unable to queue send_task_complete_email')
self.assertTrue(mock_delay.called) # noqa: PT009
self.assertEqual(hdlr.messages['error'][0], 'Unable to queue send_task_complete_email') # noqa: PT009
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Contentstore API"""
from .views.utils import course_author_access_required, get_ready_to_migrate_legacy_library_content_blocks
from .views.utils import course_author_access_required, get_ready_to_migrate_legacy_library_content_blocks # noqa: F401
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/api/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize_course(cls, course):
parent_location=cls.section.location,
category="sequential",
)
unit2 = BlockFactory.create(
unit2 = BlockFactory.create( # noqa: F841
parent_location=cls.subsection2.location,
category="vertical",
)
Expand Down
26 changes: 13 additions & 13 deletions cms/djangoapps/contentstore/api/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_anonymous_import_fails(self):
"""
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(resp.status_code, status.HTTP_401_UNAUTHORIZED) # noqa: PT009

def test_student_import_fails(self):
"""
Expand All @@ -82,7 +82,7 @@ def test_student_import_fails(self):
self.client.login(username=self.student.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN) # noqa: PT009

def test_staff_with_access_import_succeeds(self):
"""
Expand All @@ -91,7 +91,7 @@ def test_staff_with_access_import_succeeds(self):
self.client.login(username=self.staff.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.status_code, status.HTTP_200_OK) # noqa: PT009

def test_staff_has_no_access_import_fails(self):
"""
Expand All @@ -100,22 +100,22 @@ def test_staff_has_no_access_import_fails(self):
self.client.login(username=self.staff.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.restricted_course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN) # noqa: PT009

def test_student_get_status_fails(self):
"""
Test that a student user cannot access the API and an error is received.
"""
self.client.login(username=self.student.username, password=self.password)
resp = self.client.get(self.get_url(self.course_key), {'task_id': '1234', 'filename': self.good_tar_filename})
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN) # noqa: PT009

def test_anonymous_get_status_fails(self):
"""
Test that an anonymous user cannot access the API and an error is received.
"""
resp = self.client.get(self.get_url(self.course_key), {'task_id': '1234', 'filename': self.good_tar_filename})
self.assertEqual(resp.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(resp.status_code, status.HTTP_401_UNAUTHORIZED) # noqa: PT009

def test_staff_get_status_succeeds(self):
"""
Expand All @@ -126,13 +126,13 @@ def test_staff_get_status_succeeds(self):
self.client.login(username=self.staff.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.status_code, status.HTTP_200_OK) # noqa: PT009
resp = self.client.get(
self.get_url(self.course_key),
{'task_id': resp.data['task_id'], 'filename': self.good_tar_filename},
format='multipart'
)
self.assertEqual(resp.data['state'], UserTaskStatus.SUCCEEDED)
self.assertEqual(resp.data['state'], UserTaskStatus.SUCCEEDED) # noqa: PT009

def test_staff_no_access_get_status_fails(self):
"""
Expand All @@ -143,15 +143,15 @@ def test_staff_no_access_get_status_fails(self):
self.client.login(username=self.staff.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.status_code, status.HTTP_200_OK) # noqa: PT009

task_id = resp.data['task_id']
resp = self.client.get(
self.get_url(self.course_key),
{'task_id': task_id, 'filename': self.good_tar_filename},
format='multipart'
)
self.assertEqual(resp.data['state'], UserTaskStatus.SUCCEEDED)
self.assertEqual(resp.data['state'], UserTaskStatus.SUCCEEDED) # noqa: PT009

self.client.logout()

Expand All @@ -161,7 +161,7 @@ def test_staff_no_access_get_status_fails(self):
{'task_id': task_id, 'filename': self.good_tar_filename},
format='multipart'
)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN) # noqa: PT009

def test_course_task_mismatch_get_status_fails(self):
"""
Expand All @@ -172,12 +172,12 @@ def test_course_task_mismatch_get_status_fails(self):
self.client.login(username=self.staff.username, password=self.password)
with open(self.good_tar_fullpath, 'rb') as fp:
resp = self.client.post(self.get_url(self.course_key), {'course_data': fp}, format='multipart')
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.status_code, status.HTTP_200_OK) # noqa: PT009

task_id = resp.data['task_id']
resp = self.client.get(
self.get_url(self.restricted_course_key),
{'task_id': task_id, 'filename': self.good_tar_filename},
format='multipart'
)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(resp.status_code, status.HTTP_403_FORBIDDEN) # noqa: PT009
Loading
Loading