From 4dad2ab406778241b5c79d53efbfeaf00ea15ee7 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Tue, 2 Feb 2021 13:34:19 +0500 Subject: [PATCH 1/2] Applied pylint-amnesty to static_replace --- common/djangoapps/static_replace/__init__.py | 10 +++++----- .../static_replace/test/test_static_replace.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/static_replace/__init__.py b/common/djangoapps/static_replace/__init__.py index 7d2cff64d3..5319dbb3cf 100644 --- a/common/djangoapps/static_replace/__init__.py +++ b/common/djangoapps/static_replace/__init__.py @@ -1,4 +1,4 @@ - + # lint-amnesty, pylint: disable=django-not-configured, missing-module-docstring import logging import re @@ -38,7 +38,7 @@ def try_staticfiles_lookup(path): """ try: url = staticfiles_storage.url(path) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.warning("staticfiles_storage couldn't find path {0}: {1}".format( path, str(err))) # Just return the original path; don't kill everything. @@ -46,7 +46,7 @@ def try_staticfiles_lookup(path): return url -def replace_jump_to_id_urls(text, course_id, jump_to_id_base_url): +def replace_jump_to_id_urls(text, course_id, jump_to_id_base_url): # lint-amnesty, pylint: disable=unused-argument """ This will replace a link to another piece of courseware to a 'jump_to' URL that will redirect to the right place in the courseware @@ -191,7 +191,7 @@ def replace_static_urls(text, data_directory=None, course_id=None, static_asset_ exists_in_staticfiles_storage = False try: exists_in_staticfiles_storage = staticfiles_storage.exists(rest) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.warning("staticfiles_storage couldn't find path {0}: {1}".format( rest, str(err))) @@ -219,7 +219,7 @@ def replace_static_urls(text, data_directory=None, course_id=None, static_asset_ else: url = staticfiles_storage.url(course_path) # And if that fails, assume that it's course content, and add manually data directory - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.warning("staticfiles_storage couldn't find path {0}: {1}".format( rest, str(err))) url = "".join([prefix, course_path]) diff --git a/common/djangoapps/static_replace/test/test_static_replace.py b/common/djangoapps/static_replace/test/test_static_replace.py index 3ecf9c0c4b..caeaeed7f6 100644 --- a/common/djangoapps/static_replace/test/test_static_replace.py +++ b/common/djangoapps/static_replace/test/test_static_replace.py @@ -135,7 +135,7 @@ def test_mongo_filestore(mock_get_excluded_extensions, mock_get_base_url, mock_m @patch('common.djangoapps.static_replace.settings', autospec=True) @patch('xmodule.modulestore.django.modulestore', autospec=True) @patch('common.djangoapps.static_replace.staticfiles_storage', autospec=True) -def test_data_dir_fallback(mock_storage, mock_modulestore, mock_settings): +def test_data_dir_fallback(mock_storage, mock_modulestore, mock_settings): # lint-amnesty, pylint: disable=unused-argument mock_modulestore.return_value = Mock(XMLModuleStore) mock_storage.url.side_effect = Exception @@ -169,8 +169,8 @@ def test_static_url_with_query(mock_modulestore, mock_storage): mock_storage.exists.return_value = False mock_modulestore.return_value = Mock(MongoModuleStore) - pre_text = 'EMBED src ="/static/LAlec04_controller.swf?csConfigFile=/static/LAlec04_config.xml&name1=value1&name2=value2"' - post_text = 'EMBED src ="/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=%2Fc4x%2Forg%2Fcourse%2Fasset%2FLAlec04_config.xml&name1=value1&name2=value2"' + pre_text = 'EMBED src ="/static/LAlec04_controller.swf?csConfigFile=/static/LAlec04_config.xml&name1=value1&name2=value2"' # lint-amnesty, pylint: disable=line-too-long + post_text = 'EMBED src ="/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=%2Fc4x%2Forg%2Fcourse%2Fasset%2FLAlec04_config.xml&name1=value1&name2=value2"' # lint-amnesty, pylint: disable=line-too-long assert replace_static_urls(pre_text, DATA_DIRECTORY, COURSE_KEY) == post_text @@ -189,13 +189,13 @@ def test_static_paths_out(mock_modulestore, mock_storage): mock_modulestore.return_value = Mock(MongoModuleStore) static_url = '/static/LAlec04_controller.swf?csConfigFile=/static/LAlec04_config.xml&name1=value1&name2=value2' - static_course_url = '/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=%2Fc4x%2Forg%2Fcourse%2Fasset%2FLAlec04_config.xml&name1=value1&name2=value2' + static_course_url = '/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=%2Fc4x%2Forg%2Fcourse%2Fasset%2FLAlec04_config.xml&name1=value1&name2=value2' # lint-amnesty, pylint: disable=line-too-long raw_url = '/static/js/capa/protex/protex.nocache.js?raw' xblock_url = '/static/xblock/resources/babys_first.lil_xblock/public/images/pacifier.png' # xss-lint: disable=python-wrap-html pre_text = 'EMBED src ="{}" xblock={} text