Skip to content

Commit

Permalink
fix: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Sep 21, 2024
1 parent c993f0e commit a509763
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions xmodule/tests/test_util_builtin_assets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Tests for methods defined in builtin_assets.py
"""
from pathlib import PosixPath

from django.conf import settings
from unittest import TestCase
from unittest.mock import patch
Expand Down Expand Up @@ -110,9 +112,12 @@ def test_misspelled_path_raises_not_found(self):
def test_happy_path(self):
fragment = Fragment()
builtin_assets.add_css_to_fragment(fragment, "VideoBlockEditor.css")
assert fragment.resources[0] == FragmentResource(
kind='url',
data=f'{settings.REPO_ROOT}/xmodule/assets/VideoBlockEditor.css',
fr = FragmentResource(
# kind='url',
# data=f'{settings.REPO_ROOT}/xmodule/assets/VideoBlockEditor.css',
kind='text',
data=PosixPath(f"{settings.REPO_ROOT}/xmodule/assets/VideoBlockEditor.css").read_text(encoding="utf-8"),
mimetype='text/css',
placement='head',
)
assert fragment.resources[0] == fr
3 changes: 2 additions & 1 deletion xmodule/util/builtin_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def add_css_to_fragment(fragment, css_relative_path):
css_absolute_path = Path(settings.REPO_ROOT) / "xmodule" / "assets" / css_relative_path
if not css_absolute_path.is_file():
raise FileNotFoundError(f"css file not found: {css_absolute_path}")
fragment.add_css_url(str(css_absolute_path))
# fragment.add_css_url(str(css_absolute_path))
fragment.add_css(css_absolute_path.read_text(encoding='utf-8'))


def add_sass_to_fragment(fragment, sass_relative_path):
Expand Down

0 comments on commit a509763

Please sign in to comment.