Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
39e97225
Commit
39e97225
authored
Dec 09, 2013
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests.
parent
2e87b1a6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
59 deletions
+27
-59
common/lib/xmodule/xmodule/js/spec/lti/lti_spec.js
+0
-0
common/lib/xmodule/xmodule/lti_module.py
+0
-15
common/lib/xmodule/xmodule/tests/test_lti_unit.py
+6
-22
lms/djangoapps/courseware/features/lti.py
+18
-17
lms/djangoapps/courseware/tests/test_lti_integration.py
+1
-4
lms/templates/lti.html
+2
-1
No files found.
common/lib/xmodule/xmodule/js/spec/lti/lti_spec.js
deleted
100644 → 0
View file @
2e87b1a6
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/lti_module.py
View file @
39e97225
...
...
@@ -292,21 +292,6 @@ class LTIModule(LTIFields, XModule):
"""
return
Response
(
self
.
get_form
(),
content_type
=
'text/html'
)
def
handle_ajax
(
self
,
dispatch
,
__
):
"""
Ajax handler.
Args:
dispatch: string request slug
Returns:
json string
"""
if
dispatch
==
'regenerate_signature'
:
return
json
.
dumps
({
'input_fields'
:
self
.
get_input_fields
()
})
else
:
# return error message
return
json
.
dumps
({
'error'
:
'[handle_ajax]: Unknown Command!'
})
def
get_user_id
(
self
):
user_id
=
self
.
runtime
.
anonymous_student_id
assert
user_id
is
not
None
...
...
common/lib/xmodule/xmodule/tests/test_lti_unit.py
View file @
39e97225
...
...
@@ -229,6 +229,12 @@ class LTIModuleTest(LogicTest):
real_outcome_service_url
=
self
.
xmodule
.
get_outcome_service_url
()
self
.
assertEqual
(
real_outcome_service_url
,
expected_outcome_service_url
)
def
test_get_form_path
(
self
):
expected_form_path
=
self
.
xmodule
.
runtime
.
handler_url
(
self
.
xmodule
,
'preview_handler'
)
.
rstrip
(
'/?'
)
real_form_path
=
self
.
xmodule
.
get_form_path
()
self
.
assertEqual
(
real_form_path
,
expected_form_path
)
def
test_resource_link_id
(
self
):
with
patch
(
'xmodule.lti_module.LTIModule.id'
,
new_callable
=
PropertyMock
)
as
mock_id
:
mock_id
.
return_value
=
self
.
module_id
...
...
@@ -251,28 +257,6 @@ class LTIModuleTest(LogicTest):
def
test_client_key_secret
(
self
):
pass
def
test_handle_ajax
(
self
):
dispatch
=
'regenerate_signature'
data
=
''
self
.
xmodule
.
get_input_fields
=
Mock
(
return_value
=
{
'test_input_field_key'
:
'test_input_field_value'
})
json_dump
=
self
.
xmodule
.
handle_ajax
(
dispatch
,
data
)
expected_json_dump
=
'{"input_fields": {"test_input_field_key": "test_input_field_value"}}'
self
.
assertEqual
(
json
.
loads
(
json_dump
),
json
.
loads
(
expected_json_dump
)
)
def
test_handle_ajax_bad_dispatch
(
self
):
dispatch
=
'bad_dispatch'
data
=
''
self
.
xmodule
.
get_input_fields
=
Mock
(
return_value
=
{
'test_input_field_key'
:
'test_input_field_value'
})
json_dump
=
self
.
xmodule
.
handle_ajax
(
dispatch
,
data
)
expected_json_dump
=
'{"error": "[handle_ajax]: Unknown Command!"}'
self
.
assertEqual
(
json
.
loads
(
json_dump
),
json
.
loads
(
expected_json_dump
)
)
def
test_max_score
(
self
):
self
.
xmodule
.
weight
=
100.0
...
...
lms/djangoapps/courseware/features/lti.py
View file @
39e97225
...
...
@@ -13,22 +13,22 @@ from courseware.tests.factories import InstructorFactory
@step
(
'I view the LTI and error is shown$'
)
def
lti_is_not_rendered
(
_step
):
# error is shown
assert
world
.
is_css_present
(
'.error_message'
)
assert
world
.
is_css_present
(
'.error_message'
,
wait_time
=
0
)
# iframe is not presented
assert
not
world
.
is_css_present
(
'iframe'
)
assert
not
world
.
is_css_present
(
'iframe'
,
wait_time
=
0
)
# link is not presented
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
)
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
,
wait_time
=
0
)
def
check_lti_iframe_content
(
text
):
#inside iframe test content is presented
location
=
world
.
scenario_dict
[
'LTI'
]
.
location
.
html_id
()
iframe_name
=
'lti
Launch
Frame-'
+
location
iframe_name
=
'ltiFrame-'
+
location
with
world
.
browser
.
get_iframe
(
iframe_name
)
as
iframe
:
# iframe does not contain functions from terrain/ui_helpers.py
assert
iframe
.
is_element_present_by_css
(
'.result'
,
wait_time
=
5
)
assert
iframe
.
is_element_present_by_css
(
'.result'
,
wait_time
=
0
)
assert
(
text
==
world
.
retry_on_exception
(
lambda
:
iframe
.
find_by_css
(
'.result'
)[
0
]
.
text
,
max_attempts
=
5
...
...
@@ -38,18 +38,18 @@ def check_lti_iframe_content(text):
@step
(
'I view the LTI and it is rendered in (.*)$'
)
def
lti_is_rendered
(
_step
,
rendered_in
):
if
rendered_in
.
strip
()
==
'iframe'
:
assert
world
.
is_css_present
(
'iframe'
)
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
)
assert
not
world
.
is_css_present
(
'.error_message'
)
assert
world
.
is_css_present
(
'iframe'
,
wait_time
=
2
)
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
,
wait_time
=
0
)
assert
not
world
.
is_css_present
(
'.error_message'
,
wait_time
=
0
)
# iframe is visible
assert
world
.
css_visible
(
'iframe'
)
check_lti_iframe_content
(
"This is LTI tool. Success."
)
elif
rendered_in
.
strip
()
==
'new page'
:
assert
not
world
.
is_css_present
(
'iframe'
)
assert
world
.
is_css_present
(
'.link_lti_new_window'
)
assert
not
world
.
is_css_present
(
'.error_message'
)
assert
not
world
.
is_css_present
(
'iframe'
,
wait_time
=
2
)
assert
world
.
is_css_present
(
'.link_lti_new_window'
,
wait_time
=
0
)
assert
not
world
.
is_css_present
(
'.error_message'
,
wait_time
=
0
)
check_lti_popup
()
else
:
# incorrent rendered_in parameter
assert
False
...
...
@@ -57,9 +57,9 @@ def lti_is_rendered(_step, rendered_in):
@step
(
'I view the LTI but incorrect_signature warning is rendered$'
)
def
incorrect_lti_is_rendered
(
_step
):
assert
world
.
is_css_present
(
'iframe'
)
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
)
assert
not
world
.
is_css_present
(
'.error_message'
)
assert
world
.
is_css_present
(
'iframe'
,
wait_time
=
2
)
assert
not
world
.
is_css_present
(
'.link_lti_new_window'
,
wait_time
=
0
)
assert
not
world
.
is_css_present
(
'.error_message'
,
wait_time
=
0
)
#inside iframe test content is presented
check_lti_iframe_content
(
"Wrong LTI signature"
)
...
...
@@ -234,10 +234,11 @@ def check_progress(_step, text):
@step
(
'I see graph with total progress "([^"]*)"$'
)
def
see_graph
(
_step
,
progress
):
SELECTOR
=
'grade-detail-graph'
node
=
world
.
browser
.
find_by_xpath
(
'//div[@id="{parent}"]//div[text()="{progress}"]'
.
format
(
XPATH
=
'//div[@id="{parent}"]//div[text()="{progress}"]'
.
format
(
parent
=
SELECTOR
,
progress
=
progress
,
))
)
node
=
world
.
browser
.
find_by_xpath
(
XPATH
)
assert
node
...
...
@@ -259,7 +260,7 @@ def see_value_in_the_gradebook(_step, label, text):
@step
(
'I submit answer to LTI question$'
)
def
click_grade
(
_step
):
location
=
world
.
scenario_dict
[
'LTI'
]
.
location
.
html_id
()
iframe_name
=
'lti
Launch
Frame-'
+
location
iframe_name
=
'ltiFrame-'
+
location
with
world
.
browser
.
get_iframe
(
iframe_name
)
as
iframe
:
iframe
.
find_by_name
(
'submit-button'
)
.
first
.
click
()
assert
iframe
.
is_text_present
(
'LTI consumer (edX) responded with XML content'
)
...
...
lms/djangoapps/courseware/tests/test_lti_integration.py
View file @
39e97225
...
...
@@ -5,8 +5,6 @@ from . import BaseTestXmodule
from
collections
import
OrderedDict
import
mock
import
urllib
from
xmodule.lti_module
import
LTIModule
from
mock
import
Mock
class
TestLTI
(
BaseTestXmodule
):
...
...
@@ -85,7 +83,6 @@ class TestLTI(BaseTestXmodule):
Makes sure that all parameters extracted.
"""
generated_context
=
self
.
item_module
.
render
(
'student_view'
)
.
content
expected_context
=
{
'display_name'
:
self
.
item_module
.
display_name
,
'input_fields'
:
self
.
correct_headers
,
...
...
@@ -93,7 +90,7 @@ class TestLTI(BaseTestXmodule):
'element_id'
:
self
.
item_module
.
location
.
html_id
(),
'launch_url'
:
'http://www.example.com'
,
# default value
'open_in_a_new_page'
:
True
,
'
ajax_url'
:
self
.
item_descriptor
.
xmodule_runtime
.
ajax_url
,
'
form_url'
:
self
.
item_descriptor
.
xmodule_runtime
.
handler_url
(
self
.
item_module
,
'preview_handler'
)
.
rstrip
(
'/?'
)
,
}
self
.
assertEqual
(
...
...
lms/templates/lti.html
View file @
39e97225
...
...
@@ -12,7 +12,7 @@
<h3
class=
"title"
>
${display_name} (${_('External resource')})
</h3>
<p
class=
"lti-link external"
><a
target=
"_blank"
class=
'link_lti_new_window'
href=
"${form_url}"
class=
''
>
<p
class=
"lti-link external"
><a
target=
"_blank"
class=
'link_lti_new_window'
href=
"${form_url}"
>
${_('View resource in a new window')}
<i
class=
"icon-external-link"
></i>
</a></p>
...
...
@@ -21,6 +21,7 @@
## The result of the form submit will be rendered here.
<iframe
class=
"ltiLaunchFrame"
name=
"ltiFrame-${element_id}"
src=
"${form_url}"
></iframe>
% endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment