Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-utils
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
xblock-utils
Commits
da50e3fd
Commit
da50e3fd
authored
May 21, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some safeguards for theme config + tests
parent
51030839
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
tests/unit/test_settings.py
+11
-0
xblockutils/settings.py
+6
-2
No files found.
tests/unit/test_settings.py
View file @
da50e3fd
...
...
@@ -122,6 +122,7 @@ class TextThemableXBlockMixin(unittest.TestCase):
patched_resource_loader
.
assert_called_with
(
package_name
)
@ddt.data
(
(
'dummy_block'
,
[
''
]),
(
'dummy_block'
,
[
'public/themes/lms.css'
]),
(
'other_block'
,
[
'public/themes/lms.css'
,
'public/themes/lms.part2.css'
]),
(
'dummy_app.dummy_block'
,
[
'typography.css'
,
'icons.css'
]),
...
...
@@ -138,3 +139,13 @@ class TextThemableXBlockMixin(unittest.TestCase):
patched_load_unicode
.
assert_any_call
(
location
)
self
.
assertEqual
(
patched_load_unicode
.
call_count
,
len
(
locations
))
@ddt.data
(
None
,
{},
{
'locations'
:
[
'red.css'
]})
def
test_invalid_default_theme_config
(
self
,
theme_config
):
xblock
=
DummyXBlockWithSettings
(
self
.
runtime_mock
,
scope_ids
=
Mock
())
xblock
.
default_theme_config
=
theme_config
self
.
service_mock
.
get_settings_bucket
=
Mock
(
return_value
=
{})
fragment
=
MagicMock
()
with
patch
(
"xblockutils.settings.ResourceLoader.load_unicode"
)
as
patched_load_unicode
:
xblock
.
include_theme_files
(
fragment
)
patched_load_unicode
.
assert_not_called
()
xblockutils/settings.py
View file @
da50e3fd
...
...
@@ -82,6 +82,10 @@ class ThemableXBlockMixin(object):
Gets theme configuration and renders theme css into fragment
"""
theme
=
self
.
get_theme
()
theme_package
,
theme_files
=
theme
[
'package'
],
theme
[
'locations'
]
if
not
theme
or
'package'
not
in
theme
:
return
theme_package
,
theme_files
=
theme
.
get
(
'package'
,
None
),
theme
.
get
(
'locations'
,
[])
resource_loader
=
ResourceLoader
(
theme_package
)
for
theme_file
in
theme_files
:
fragment
.
add_css
(
ResourceLoader
(
theme_package
)
.
load_unicode
(
theme_file
))
fragment
.
add_css
(
resource_loader
.
load_unicode
(
theme_file
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment