refactor: xmodule/lti_module.py -> xmodule/lti_block.py

This commit is contained in:
0x29a
2022-10-26 21:05:58 +02:00
committed by Piotr Surowiec
parent e3591701e3
commit 2779bd250f
11 changed files with 27 additions and 27 deletions

View File

@@ -14,7 +14,7 @@ from web_fragments.fragment import Fragment
from xblock.core import XBlock, XBlockAside
from xmodule.contentstore.django import contentstore
from xmodule.lti_module import LTIBlock
from xmodule.lti_block import LTIBlock
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import (

View File

@@ -234,7 +234,7 @@ class StubLtiHandler(StubHttpRequestHandler):
</html>
""")).format(response=response_text, role=role, submit_form=submit_form)
# Currently LTI module doublequotes the lis_result_sourcedid parameter.
# Currently LTI block doublequotes the lis_result_sourcedid parameter.
# Unquote response two times.
return six.moves.urllib.parse.unquote(six.moves.urllib.parse.unquote(response_str))

View File

@@ -127,7 +127,7 @@ class TestLTI(BaseTestXmodule):
class TestLTIBlockListing(SharedModuleStoreTestCase):
"""
a test for the rest endpoint that lists LTI modules in a course
a test for the rest endpoint that lists LTI blocks in a course
"""
# arbitrary constant
COURSE_SLUG = "100"
@@ -154,7 +154,7 @@ class TestLTIBlockListing(SharedModuleStoreTestCase):
display_name="section2",
category='sequential')
# creates one draft and one published lti module, in different sections
# creates one draft and one published lti block, in different sections
cls.lti_published = ItemFactory.create(
parent_location=cls.section1.location,
display_name="lti published",
@@ -189,7 +189,7 @@ class TestLTIBlockListing(SharedModuleStoreTestCase):
assert 404 == response.status_code
def test_lti_rest_listing(self):
"""tests that the draft lti module is part of the endpoint response"""
"""tests that the draft lti block is part of the endpoint response"""
request = mock.Mock()
request.method = 'GET'
response = get_course_lti_endpoints(request, course_id=str(self.course.id))

View File

@@ -45,7 +45,7 @@ from xmodule.capa.xqueue_interface import XQueueInterface
from xmodule.capa_block import ProblemBlock
from xmodule.contentstore.django import contentstore
from xmodule.html_block import AboutBlock, CourseInfoBlock, HtmlBlock, StaticTabBlock
from xmodule.lti_module import LTIBlock
from xmodule.lti_block import LTIBlock
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import ModuleI18nService, modulestore
from xmodule.modulestore.tests.django_utils import (

View File

@@ -12,7 +12,7 @@ from openedx.core.djangolib.js_utils import js_escaped_string
</head>
<body>
## This form will be hidden.
## LTI module JavaScript will trigger a "submit" on the form, and the
## LTI block JavaScript will trigger a "submit" on the form, and the
## result will be rendered instead.
<form
id="lti-${element_id}"

View File

@@ -23,7 +23,7 @@ XBLOCKS = [
"library = xmodule.library_root_xblock:LibraryRoot",
"library_content = xmodule.library_content_block:LibraryContentBlock",
"library_sourced = xmodule.library_sourced_block:LibrarySourcedBlock",
"lti = xmodule.lti_module:LTIBlock",
"lti = xmodule.lti_block:LTIBlock",
"poll_question = xmodule.poll_module:PollBlock",
"problem = xmodule.capa_block:ProblemBlock",
"randomize = xmodule.randomize_module:RandomizeBlock",

View File

@@ -713,7 +713,7 @@ class LTIBlock(
# https://github.com/idan/oauthlib/blob/master/oauthlib/oauth1/rfc5849/signature.py#L136
# Stubbing headers for now:
log.info(
"LTI module %s in course %s does not have oauth parameters correctly configured.",
"LTI block %s in course %s does not have oauth parameters correctly configured.",
self.location,
self.location.course_key,
)

View File

@@ -24,7 +24,7 @@ from xmodule.capa_block import ProblemBlock
from xmodule.conditional_block import ConditionalBlock
from xmodule.html_block import AboutBlock, CourseInfoBlock, HtmlBlock, StaticTabBlock
from xmodule.library_content_block import LibraryContentBlock
from xmodule.lti_module import LTIBlock
from xmodule.lti_block import LTIBlock
from xmodule.poll_module import PollBlock
from xmodule.seq_module import SequenceBlock
from xmodule.split_test_module import SplitTestBlock

View File

@@ -10,14 +10,14 @@ from pytz import UTC
from xblock.field_data import DictFieldData
from xmodule.lti_2_util import LTIError
from xmodule.lti_module import LTIBlock
from xmodule.lti_block import LTIBlock
from xmodule.tests.helpers import StubUserService
from . import get_test_system
class LTI20RESTResultServiceTest(unittest.TestCase):
"""Logic tests for LTI module. LTI2.0 REST ResultService"""
"""Logic tests for LTI block. LTI2.0 REST ResultService"""
USER_STANDIN = Mock()
USER_STANDIN.id = 999

View File

@@ -23,7 +23,7 @@ from xblock.fields import ScopeIds
from common.djangoapps.xblock_django.constants import ATTR_KEY_ANONYMOUS_USER_ID
from xmodule.fields import Timedelta
from xmodule.lti_2_util import LTIError
from xmodule.lti_module import LTIBlock
from xmodule.lti_block import LTIBlock
from xmodule.tests.helpers import StubUserService
from . import get_test_system
@@ -31,7 +31,7 @@ from . import get_test_system
@override_settings(LMS_BASE="edx.org")
class LTIBlockTest(TestCase):
"""Logic tests for LTI module."""
"""Logic tests for LTI block."""
def setUp(self):
super().setUp()
@@ -127,7 +127,7 @@ class LTIBlockTest(TestCase):
}
@patch(
'xmodule.lti_module.LTIBlock.get_client_key_secret',
'xmodule.lti_block.LTIBlock.get_client_key_secret',
return_value=('test_client_key', 'test_client_secret')
)
def test_authorization_header_not_present(self, _get_key_secret):
@@ -151,7 +151,7 @@ class LTIBlockTest(TestCase):
self.assertDictEqual(expected_response, real_response)
@patch(
'xmodule.lti_module.LTIBlock.get_client_key_secret',
'xmodule.lti_block.LTIBlock.get_client_key_secret',
return_value=('test_client_key', 'test_client_secret')
)
def test_authorization_header_empty(self, _get_key_secret):
@@ -313,7 +313,7 @@ class LTIBlockTest(TestCase):
assert real_outcome_service_url == (mock_url_prefix + test_service_name)
def test_resource_link_id(self):
with patch('xmodule.lti_module.LTIBlock.location', new_callable=PropertyMock):
with patch('xmodule.lti_block.LTIBlock.location', new_callable=PropertyMock):
self.xmodule.location.html_id = lambda: 'i4x-2-3-lti-31de800015cf4afb973356dbe81496df'
expected_resource_link_id = str(parse.quote(self.unquoted_resource_link_id))
real_resource_link_id = self.xmodule.get_resource_link_id()
@@ -330,7 +330,7 @@ class LTIBlockTest(TestCase):
def test_client_key_secret(self):
"""
LTI module gets client key and secret provided.
LTI block gets client key and secret provided.
"""
#this adds lti passports to system
mocked_course = Mock(lti_passports=['lti_id:test_client:test_secret'])
@@ -345,7 +345,7 @@ class LTIBlockTest(TestCase):
def test_client_key_secret_not_provided(self):
"""
LTI module attempts to get client key and secret provided in cms.
LTI block attempts to get client key and secret provided in cms.
There are key and secret but not for specific LTI.
"""
@@ -364,7 +364,7 @@ class LTIBlockTest(TestCase):
def test_bad_client_key_secret(self):
"""
LTI module attempts to get client key and secret provided in cms.
LTI block attempts to get client key and secret provided in cms.
There are key and secret provided in wrong format.
"""
@@ -378,9 +378,9 @@ class LTIBlockTest(TestCase):
with pytest.raises(LTIError):
self.xmodule.get_client_key_secret()
@patch('xmodule.lti_module.signature.verify_hmac_sha1', Mock(return_value=True))
@patch('xmodule.lti_block.signature.verify_hmac_sha1', Mock(return_value=True))
@patch(
'xmodule.lti_module.LTIBlock.get_client_key_secret',
'xmodule.lti_block.LTIBlock.get_client_key_secret',
Mock(return_value=('test_client_key', 'test_client_secret'))
)
def test_successful_verify_oauth_body_sign(self):
@@ -389,8 +389,8 @@ class LTIBlockTest(TestCase):
"""
self.xmodule.verify_oauth_body_sign(self.get_signed_grade_mock_request())
@patch('xmodule.lti_module.LTIBlock.get_outcome_service_url', Mock(return_value='https://testurl/'))
@patch('xmodule.lti_module.LTIBlock.get_client_key_secret',
@patch('xmodule.lti_block.LTIBlock.get_outcome_service_url', Mock(return_value='https://testurl/'))
@patch('xmodule.lti_block.LTIBlock.get_client_key_secret',
Mock(return_value=('__consumer_key__', '__lti_secret__')))
def test_failed_verify_oauth_body_sign_proxy_mangle_url(self):
"""
@@ -460,9 +460,9 @@ class LTIBlockTest(TestCase):
assert self.defaults['grade'] == grade
assert self.defaults['action'] == action
@patch('xmodule.lti_module.signature.verify_hmac_sha1', Mock(return_value=False))
@patch('xmodule.lti_block.signature.verify_hmac_sha1', Mock(return_value=False))
@patch(
'xmodule.lti_module.LTIBlock.get_client_key_secret',
'xmodule.lti_block.LTIBlock.get_client_key_secret',
Mock(return_value=('test_client_key', 'test_client_secret'))
)
def test_failed_verify_oauth_body_sign(self):

View File

@@ -1620,7 +1620,7 @@ class ModuleSystemShim:
def rebind_noauth_module_to_user(self):
"""
A function that was used to bind modules initialized by AnonymousUsers to real users. Mainly used
by the LTI Module to connect the right users with the requests from LTI tools.
by the LTI Block to connect the right users with the requests from LTI tools.
Deprecated in favour of the "rebind_user" service.
"""