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
d5639293
Commit
d5639293
authored
Sep 05, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add correct acceptance tests for LTI
parent
462a42e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
93 deletions
+65
-93
lms/djangoapps/courseware/features/lti.feature
+7
-3
lms/djangoapps/courseware/features/lti.py
+58
-90
No files found.
lms/djangoapps/courseware/features/lti.feature
View file @
d5639293
...
...
@@ -2,13 +2,16 @@ Feature: LTI component
As a student, I want to view LTI component in LMS.
Scenario
:
LTI component in LMS is not rendered
Given
the course has a LTI component with empty fields
Given
the course has correct LTI credentials
And
the course has a LTI component with incorrect fields
Then
I view the LTI and it is not rendered
Scenario
:
LTI component in LMS is rendered
Given
the course has a LTI component filled with correct data
Given
the course has correct LTI credentials
And
the course has a LTI component filled with correct fields
Then
I view the LTI and it is rendered
Scenario
:
LTI component in LMS is rendered incorreclty
Given
the course has a LTI component filled with correct url and client_key, but incorrect client_secret
Given
the course has a incorrect LTI credentials
And
the course has a LTI component filled with correct fields
Then
I view the LTI but incorrect_signature warning is rendered
\ No newline at end of file
lms/djangoapps/courseware/features/lti.py
View file @
d5639293
...
...
@@ -5,15 +5,10 @@ from lettuce import world, step
from
lettuce.django
import
django_url
from
common
import
section_location
,
course_id
from
django.contrib.auth.models
import
User
from
student.models
import
CourseEnrollment
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.course_module
import
CourseDescriptor
from
courseware.courses
import
get_course_by_id
from
xmodule
import
seq_module
,
vertical_module
@step
(
'I view the LTI and it is not rendered'
)
@step
(
'I view the LTI and it is not rendered$'
)
def
lti_is_not_rendered
(
_step
):
# lti div has no class rendered
assert
world
.
is_css_not_present
(
'div.lti.rendered'
)
...
...
@@ -30,7 +25,7 @@ def lti_is_not_rendered(_step):
assert
iframe
.
is_element_not_present_by_css
(
'.result'
,
wait_time
=
5
)
@step
(
'I view the LTI and it is rendered'
)
@step
(
'I view the LTI and it is rendered
$
'
)
def
lti_is_rendered
(
_step
):
# lti div has class rendered
assert
world
.
is_css_present
(
'div.lti.rendered'
)
...
...
@@ -51,7 +46,7 @@ def lti_is_rendered(_step):
))
@step
(
'I view the LTI but incorrect_signature warning is rendered'
)
@step
(
'I view the LTI but incorrect_signature warning is rendered
$
'
)
def
incorrect_lti_is_rendered
(
_step
):
# lti div has class rendered
assert
world
.
is_css_present
(
'div.lti.rendered'
)
...
...
@@ -72,108 +67,80 @@ def incorrect_lti_is_rendered(_step):
))
@step
(
'the course has
a LTI component filled with correct data
'
)
def
view_lti_with_data
(
_step
):
@step
(
'the course has
correct LTI credentials$
'
)
def
set_correct_lti_passport
(
_step
):
coursenum
=
'test_course'
metadata
=
{
'LTIs'
:
[
"
tes
t_lti_id:{}:{}"
.
format
(
metadata
=
{
'LTIs'
:
[
"
correc
t_lti_id:{}:{}"
.
format
(
world
.
lti_server
.
oauth_settings
[
'client_key'
],
world
.
lti_server
.
oauth_settings
[
'client_secret'
]
)]
}
i_am_registered_for_the_course
(
_step
,
coursenum
,
metadata
)
add_correct_lti_to_course
(
coursenum
)
chapter_name
=
world
.
scenario_dict
[
'SECTION'
]
.
display_name
.
replace
(
" "
,
"_"
)
section_name
=
chapter_name
url
=
django_url
(
'/courses/
%
s/
%
s/
%
s/courseware/
%
s/
%
s'
%
(
world
.
scenario_dict
[
'COURSE'
]
.
org
,
world
.
scenario_dict
[
'COURSE'
]
.
number
,
world
.
scenario_dict
[
'COURSE'
]
.
display_name
.
replace
(
' '
,
'_'
),
chapter_name
,
section_name
,)
)
world
.
browser
.
visit
(
url
)
i_am_registered_for_the_course
(
coursenum
,
metadata
)
@step
(
'the course has a
LTI component with empty fields
'
)
def
view_default_lti
(
_step
):
@step
(
'the course has a
incorrect LTI credentials$
'
)
def
set_incorrect_lti_passport
(
_step
):
coursenum
=
'test_course'
metadata
=
{}
i_am_registered_for_the_course
(
_step
,
coursenum
,
{})
add_default_lti_to_course
(
coursenum
)
chapter_name
=
world
.
scenario_dict
[
'SECTION'
]
.
display_name
.
replace
(
" "
,
"_"
)
section_name
=
chapter_name
url
=
django_url
(
'/courses/
%
s/
%
s/
%
s/courseware/
%
s/
%
s'
%
(
world
.
scenario_dict
[
'COURSE'
]
.
org
,
world
.
scenario_dict
[
'COURSE'
]
.
number
,
world
.
scenario_dict
[
'COURSE'
]
.
display_name
.
replace
(
' '
,
'_'
),
chapter_name
,
section_name
,)
)
world
.
browser
.
visit
(
url
)
@step
(
'the course has a LTI component filled with correct url
\
and client_key, but incorrect client_secret'
)
def
view_wrong_data_lti
(
_step
):
coursenum
=
'test_course'
metadata
=
{
metadata
=
{
'LTIs'
:
[
"test_lti_id:{}:{}"
.
format
(
world
.
lti_server
.
oauth_settings
[
'client_key'
],
world
.
lti_server
.
oauth_settings
[
'client_secret'
]
"incorrect_lti_secret_key"
)]
}
i_am_registered_for_the_course
(
_step
,
coursenum
,
metadata
)
wrong_data_lti_to_course
(
coursenum
)
chapter_name
=
world
.
scenario_dict
[
'SECTION'
]
.
display_name
.
replace
(
" "
,
"_"
)
section_name
=
chapter_name
url
=
django_url
(
'/courses/
%
s/
%
s/
%
s/courseware/
%
s/
%
s'
%
(
world
.
scenario_dict
[
'COURSE'
]
.
org
,
world
.
scenario_dict
[
'COURSE'
]
.
number
,
world
.
scenario_dict
[
'COURSE'
]
.
display_name
.
replace
(
' '
,
'_'
),
chapter_name
,
section_name
,)
)
world
.
browser
.
visit
(
url
)
i_am_registered_for_the_course
(
coursenum
,
metadata
)
def
add_correct_lti_to_course
(
course
):
@step
(
'the course has a LTI component filled with correct fields$'
)
def
add_correct_lti_to_course
(
_step
):
category
=
'lti'
world
.
ItemFactory
.
create
(
parent_location
=
section_location
(
course
),
# parent_location=section_location(course),
parent_location
=
world
.
scenario_dict
[
'SEQUENTIAL'
]
.
location
,
category
=
category
,
display_name
=
'LTI'
,
metadata
=
{
'lti_id'
:
'
tes
t_lti_id'
,
'lti_id'
:
'
correc
t_lti_id'
,
'launch_url'
:
world
.
lti_server
.
oauth_settings
[
'lti_base'
]
+
world
.
lti_server
.
oauth_settings
[
'lti_endpoint'
]
}
)
def
add_default_lti_to_course
(
course
):
category
=
'lti'
world
.
ItemFactory
.
create
(
parent_location
=
section_location
(
course
)
,
category
=
category
,
display_name
=
'LTI'
chapter_name
=
world
.
scenario_dict
[
'SECTION'
]
.
display_name
.
replace
(
" "
,
"_"
)
section_name
=
chapter_name
url
=
django_url
(
'/courses/
%
s/
%
s/
%
s/courseware/
%
s/
%
s'
%
(
world
.
scenario_dict
[
'COURSE'
]
.
org
,
world
.
scenario_dict
[
'COURSE'
]
.
number
,
world
.
scenario_dict
[
'COURSE'
]
.
display_name
.
replace
(
' '
,
'_'
)
,
chapter_name
,
section_name
,)
)
world
.
browser
.
visit
(
url
)
def
wrong_data_lti_to_course
(
course
):
@step
(
'the course has a LTI component with incorrect fields$'
)
def
add_incorrect_lti_to_course
(
_step
):
category
=
'lti'
world
.
ItemFactory
.
create
(
parent_location
=
section_location
(
course
)
,
parent_location
=
world
.
scenario_dict
[
'SEQUENTIAL'
]
.
location
,
category
=
category
,
display_name
=
'LTI'
,
metadata
=
{
'lti_id'
:
'
tes
t_lti_id'
,
'lti_id'
:
'
incorrec
t_lti_id'
,
'lti_url'
:
world
.
lti_server
.
oauth_settings
[
'lti_base'
]
+
world
.
lti_server
.
oauth_settings
[
'lti_endpoint'
]
}
)
chapter_name
=
world
.
scenario_dict
[
'SECTION'
]
.
display_name
.
replace
(
" "
,
"_"
)
section_name
=
chapter_name
url
=
django_url
(
'/courses/
%
s/
%
s/
%
s/courseware/
%
s/
%
s'
%
(
world
.
scenario_dict
[
'COURSE'
]
.
org
,
world
.
scenario_dict
[
'COURSE'
]
.
number
,
world
.
scenario_dict
[
'COURSE'
]
.
display_name
.
replace
(
' '
,
'_'
),
chapter_name
,
section_name
,)
)
world
.
browser
.
visit
(
url
)
@step
(
u'The course "([^"]*)" exists$'
)
def
create_course
(
_step
,
course
,
metadata
):
def
create_course
(
course
,
metadata
):
# First clear the modulestore so we don't try to recreate
# the same course twice
...
...
@@ -183,32 +150,33 @@ def create_course(_step, course, metadata):
# Create the course
# We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x)
world
.
scenario_dict
[
'COURSE'
]
=
world
.
CourseFactory
.
create
(
org
=
'edx'
,
number
=
course
,
display_name
=
'Test Course'
,
metadata
=
metadata
)
world
.
scenario_dict
[
'COURSE'
]
=
world
.
CourseFactory
.
create
(
org
=
'edx'
,
number
=
course
,
display_name
=
'Test Course'
,
metadata
=
metadata
)
# Add a section to the course to contain problems
world
.
scenario_dict
[
'SECTION'
]
=
world
.
ItemFactory
.
create
(
parent_location
=
world
.
scenario_dict
[
'COURSE'
]
.
location
,
display_name
=
'Test Section'
)
world
.
ItemFactory
.
create
(
world
.
scenario_dict
[
'SECTION'
]
=
world
.
ItemFactory
.
create
(
parent_location
=
world
.
scenario_dict
[
'COURSE'
]
.
location
,
display_name
=
'Test Section'
)
world
.
scenario_dict
[
'SEQUENTIAL'
]
=
world
.
ItemFactory
.
create
(
parent_location
=
world
.
scenario_dict
[
'SECTION'
]
.
location
,
category
=
'sequential'
,
display_name
=
'Test Section'
)
@step
(
u'I am registered for the course "([^"]*)"$'
)
def
i_am_registered_for_the_course
(
step
,
course
,
metadata
):
def
i_am_registered_for_the_course
(
course
,
metadata
):
# Create the course
create_course
(
step
,
course
,
metadata
)
create_course
(
course
,
metadata
)
# Create the user
world
.
create_user
(
'robot'
,
'test'
)
u
=
User
.
objects
.
get
(
username
=
'robot'
)
u
sr
=
User
.
objects
.
get
(
username
=
'robot'
)
# If the user is not already enrolled, enroll the user.
# TODO: change to factory
CourseEnrollment
.
enroll
(
u
,
course_id
(
course
))
CourseEnrollment
.
enroll
(
usr
,
course_id
(
course
))
world
.
log_in
(
username
=
'robot'
,
password
=
'test'
)
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