From b5a7c838ff3d6158cf9ace2a3fb2f120f589304e Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Tue, 12 Mar 2024 09:59:11 +1030 Subject: [PATCH] fix: improve test coverage % and fix formatting --- platform_plugin_aspects/tests/test_utils.py | 2 +- platform_plugin_aspects/tests/test_xblock.py | 17 +++++++++++++++++ platform_plugin_aspects/xblock.py | 4 +--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/platform_plugin_aspects/tests/test_utils.py b/platform_plugin_aspects/tests/test_utils.py index 607fc5a..8356757 100644 --- a/platform_plugin_aspects/tests/test_utils.py +++ b/platform_plugin_aspects/tests/test_utils.py @@ -99,7 +99,7 @@ def test_get_ccx_courses_feature_disabled(self): "SUPERSET_CONFIG", { "internal_service_url": "http://superset:8088", - "service_url": "http://superset-dummy-url", + "service_url": "http://superset-dummy-url/", "username": "superset", "password": "superset", }, diff --git a/platform_plugin_aspects/tests/test_xblock.py b/platform_plugin_aspects/tests/test_xblock.py index a4882e6..e38c1a1 100644 --- a/platform_plugin_aspects/tests/test_xblock.py +++ b/platform_plugin_aspects/tests/test_xblock.py @@ -90,3 +90,20 @@ def test_render_translations( url_resource = resource self.assertIsNotNone(url_resource, "No 'url' resource found in fragment") self.assertIn("eo/text.js", url_resource.data) + + @patch("platform_plugin_aspects.xblock.translation.get_language") + @patch("platform_plugin_aspects.utils._generate_guest_token") + def test_render_no_translations( + self, + mock_generate_guest_token, + mock_get_language, + ): + """ + Ensure translated javascript is served. + """ + mock_generate_guest_token.return_value = ("test-token", "test-dashboard-uuid") + mock_get_language.return_value = None + xblock = make_an_xblock("instructor") + student_view = xblock.student_view() + for resource in student_view.resources: + assert resource.kind != "url" diff --git a/platform_plugin_aspects/xblock.py b/platform_plugin_aspects/xblock.py index fa560ec..73e334c 100644 --- a/platform_plugin_aspects/xblock.py +++ b/platform_plugin_aspects/xblock.py @@ -110,9 +110,7 @@ def student_view(self, context=None): context["xblock_id"] = str(self.scope_ids.usage_id.block_id) frag = Fragment() - frag.add_content( - self.render_template("static/html/superset.html", context) - ) + frag.add_content(self.render_template("static/html/superset.html", context)) frag.add_css(loader.load_unicode("static/css/superset.css")) frag.add_javascript(loader.load_unicode("static/js/install_required.js"))