From a5097630092aaed9cf46389e63a8ba9c5d1c38e7 Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Khan Date: Sat, 21 Sep 2024 16:14:49 +0500 Subject: [PATCH] fix: fixes --- xmodule/tests/test_util_builtin_assets.py | 11 ++++++++--- xmodule/util/builtin_assets.py | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xmodule/tests/test_util_builtin_assets.py b/xmodule/tests/test_util_builtin_assets.py index acfd3806d09b..1e5ccef4e050 100644 --- a/xmodule/tests/test_util_builtin_assets.py +++ b/xmodule/tests/test_util_builtin_assets.py @@ -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 @@ -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 diff --git a/xmodule/util/builtin_assets.py b/xmodule/util/builtin_assets.py index 5864e8a3c30f..218609fa709f 100644 --- a/xmodule/util/builtin_assets.py +++ b/xmodule/util/builtin_assets.py @@ -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):