Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttqureshi committed Feb 12, 2025
1 parent e3ddaf1 commit 15b064b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lms/djangoapps/courseware/tests/test_lti_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import OrderedDict

from unittest import mock
from unittest.mock import patch
import urllib
import oauthlib
from django.conf import settings
Expand All @@ -16,6 +17,7 @@
from openedx.core.lib.url_utils import quote_slashes
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.tests.helpers import mock_render_template


class TestLTI(BaseTestXmodule):
Expand Down Expand Up @@ -115,14 +117,26 @@ def mocked_sign(self, *args, **kwargs):
patcher.start()
self.addCleanup(patcher.stop)

def test_lti_constructor(self):
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
def test_lti_constructor(self, mock_render_django_template):
generated_content = self.block.student_view(None).content
expected_content = self.runtime.render_template('lti.html', self.expected_context)

if settings.USE_EXTRACTED_LTI_BLOCK:
expected_content = self.runtime.render_template('templates/lti.html', self.expected_context)
mock_render_django_template.assert_called_once()
else:
expected_content = self.runtime.render_template('lti.html', self.expected_context)
assert generated_content == expected_content

def test_lti_preview_handler(self):
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
def test_lti_preview_handler(self, mock_render_django_template):
generated_content = self.block.preview_handler(None, None).body
expected_content = self.runtime.render_template('lti_form.html', self.expected_context)

if settings.USE_EXTRACTED_LTI_BLOCK:
expected_content = self.runtime.render_template('templates/lti_form.html', self.expected_context)
mock_render_django_template.assert_called_once()
else:
expected_content = self.runtime.render_template('lti_form.html', self.expected_context)
assert generated_content.decode('utf-8') == expected_content


Expand Down

0 comments on commit 15b064b

Please sign in to comment.