Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
a5143e06
Unverified
Commit
a5143e06
authored
4 years ago
by
Usama Sadiq
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #26302 from edx/amnesty-static-replace
Applied pylint-amnesty to static_replace
parents
8529e433
edfced07
No related branches found
Branches containing commit
Tags
release-2021-04-26-14.10
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/static_replace/__init__.py
+5
-5
5 additions, 5 deletions
common/djangoapps/static_replace/__init__.py
common/djangoapps/static_replace/test/test_static_replace.py
+5
-5
5 additions, 5 deletions
common/djangoapps/static_replace/test/test_static_replace.py
with
10 additions
and
10 deletions
common/djangoapps/static_replace/__init__.py
+
5
−
5
View file @
a5143e06
# 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
])
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/static_replace/test/test_static_replace.py
+
5
−
5
View file @
a5143e06
...
...
@@ -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 <tag a=
"
{}
"
/><div class=
"'
.
format
(
static_url
,
xblock_url
,
raw_url
)
# xss-lint: disable=python-wrap-html
post_text
=
'
EMBED src =
"
{}
"
xblock={} text <tag a=
"
{}
"
/><div class=
"'
.
format
(
static_course_url
,
xblock_url
,
raw_url
)
post_text
=
'
EMBED src =
"
{}
"
xblock={} text <tag a=
"
{}
"
/><div class=
"'
.
format
(
static_course_url
,
xblock_url
,
raw_url
)
# lint-amnesty, pylint: disable=line-too-long
static_paths
=
[]
assert
replace_static_urls
(
pre_text
,
DATA_DIRECTORY
,
COURSE_KEY
,
static_paths_out
=
static_paths
)
==
post_text
assert
static_paths
==
[(
static_url
,
static_course_url
),
(
raw_url
,
raw_url
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment