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
4528490f
Commit
4528490f
authored
Mar 22, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored lms/coureware lettuce tests to use terrain helpers
for common ui manipulations
parent
6dd86f7a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
50 additions
and
28 deletions
+50
-28
common/djangoapps/terrain/course_helpers.py
+1
-0
common/djangoapps/terrain/steps.py
+5
-1
common/djangoapps/terrain/ui_helpers.py
+22
-1
lms/djangoapps/courseware/features/courseware_common.py
+6
-7
lms/djangoapps/courseware/features/login.py
+1
-3
lms/djangoapps/courseware/features/openended.py
+2
-4
lms/djangoapps/courseware/features/problems.py
+2
-2
lms/djangoapps/courseware/features/registration.py
+4
-4
lms/djangoapps/courseware/features/signup.py
+1
-1
lms/djangoapps/courseware/features/smart-accordion.py
+5
-5
lms/djangoapps/courseware/features/xqueue_setup.py
+1
-0
No files found.
common/djangoapps/terrain/course_helpers.py
View file @
4528490f
...
...
@@ -12,6 +12,7 @@ import os.path
from
urllib
import
quote_plus
from
lettuce.django
import
django_url
@world.absorb
def
create_user
(
uname
):
...
...
common/djangoapps/terrain/steps.py
View file @
4528490f
...
...
@@ -13,6 +13,7 @@ logger = getLogger(__name__)
def
wait
(
step
,
seconds
):
world
.
wait
(
seconds
)
@step
(
'I reload the page$'
)
def
reload_the_page
(
step
):
world
.
browser
.
reload
()
...
...
@@ -72,10 +73,12 @@ def the_page_title_should_be(step, title):
def
the_page_title_should_contain
(
step
,
title
):
assert
(
title
in
world
.
browser
.
title
)
@step
(
'I log in$'
)
def
i_log_in
(
step
):
world
.
log_in
(
'robot'
,
'test'
)
@step
(
'I am a logged in user$'
)
def
i_am_logged_in_user
(
step
):
world
.
create_user
(
'robot'
)
...
...
@@ -101,10 +104,12 @@ def click_the_link_called(step, text):
def
should_have_the_url
(
step
,
url
):
assert_equals
(
world
.
browser
.
url
,
url
)
@step
(
r'should see (?:the|a) link (?:called|with the text) "([^"]*)"$'
)
def
should_see_a_link_called
(
step
,
text
):
assert
len
(
world
.
browser
.
find_link_by_text
(
text
))
>
0
@step
(
r'should see "(.*)" (?:somewhere|anywhere) in (?:the|this) page'
)
def
should_see_in_the_page
(
step
,
text
):
assert_in
(
text
,
world
.
browser
.
html
)
...
...
@@ -130,4 +135,3 @@ def i_am_an_edx_user(step):
@step
(
u'User "([^"]*)" is an edX user$'
)
def
registered_edx_user
(
step
,
uname
):
world
.
create_user
(
uname
)
common/djangoapps/terrain/ui_helpers.py
View file @
4528490f
...
...
@@ -2,6 +2,8 @@ from lettuce import world, step
import
time
from
urllib
import
quote_plus
from
selenium.common.exceptions
import
WebDriverException
from
lettuce.django
import
django_url
@world.absorb
def
wait
(
seconds
):
...
...
@@ -9,6 +11,21 @@ def wait(seconds):
@world.absorb
def
visit
(
url
):
world
.
browser
.
visit
(
django_url
(
url
))
@world.absorb
def
url_equals
(
url
):
return
world
.
browser
.
url
==
django_url
(
url
)
@world.absorb
def
is_css_present
(
css_selector
):
return
world
.
browser
.
is_element_present_by_css
(
css_selector
,
wait_time
=
4
)
@world.absorb
def
css_click
(
css_selector
):
try
:
world
.
browser
.
find_by_css
(
css_selector
)
.
click
()
...
...
@@ -20,22 +37,27 @@ def css_click(css_selector):
time
.
sleep
(
1
)
world
.
browser
.
find_by_css
(
css_selector
)
.
click
()
@world.absorb
def
css_fill
(
css_selector
,
text
):
world
.
browser
.
find_by_css
(
css_selector
)
.
first
.
fill
(
text
)
@world.absorb
def
click_link
(
partial_text
):
world
.
browser
.
find_link_by_partial_text
(
partial_text
)
.
first
.
click
()
@world.absorb
def
css_text
(
css_selector
):
return
world
.
browser
.
find_by_css
(
css_selector
)
.
first
.
text
@world.absorb
def
css_visible
(
css_selector
):
return
world
.
browser
.
find_by_css
(
css_selector
)
.
visible
@world.absorb
def
save_the_html
(
path
=
'/tmp'
):
u
=
world
.
browser
.
url
...
...
@@ -44,4 +66,3 @@ def save_the_html(path='/tmp'):
f
=
open
(
'
%
s/
%
s'
%
(
path
,
filename
),
'w'
)
f
.
write
(
html
)
f
.
close
lms/djangoapps/courseware/features/courseware_common.py
View file @
4528490f
from
lettuce
import
world
,
step
from
lettuce.django
import
django_url
@step
(
'I click on View Courseware'
)
def
i_click_on_view_courseware
(
step
):
css
=
'a.enter-course'
world
.
browser
.
find_by_css
(
css
)
.
first
.
click
()
world
.
css_click
(
'a.enter-course'
)
@step
(
'I click on the "([^"]*)" tab$'
)
...
...
@@ -13,10 +11,10 @@ def i_click_on_the_tab(step, tab_text):
world
.
click_link
(
tab_text
)
world
.
save_the_html
()
@step
(
'I visit the courseware URL$'
)
def
i_visit_the_course_info_url
(
step
):
url
=
django_url
(
'/courses/MITx/6.002x/2012_Fall/courseware'
)
world
.
browser
.
visit
(
url
)
world
.
visit
(
'/courses/MITx/6.002x/2012_Fall/courseware'
)
@step
(
u'I do not see "([^"]*)" anywhere on the page'
)
...
...
@@ -26,14 +24,15 @@ def i_do_not_see_text_anywhere_on_the_page(step, text):
@step
(
u'I am on the dashboard page$'
)
def
i_am_on_the_dashboard_page
(
step
):
assert
world
.
browser
.
is_element_present_by_css
(
'section.courses'
)
assert
world
.
browser
.
url
==
django_url
(
'/dashboard'
)
assert
world
.
is_css_present
(
'section.courses'
)
assert
world
.
url_equals
(
'/dashboard'
)
@step
(
'the "([^"]*)" tab is active$'
)
def
the_tab_is_active
(
step
,
tab_text
):
assert
world
.
css_text
(
'.course-tabs a.active'
)
==
tab_text
@step
(
'the login dialog is visible$'
)
def
login_dialog_visible
(
step
):
assert
world
.
css_visible
(
'form#login_form.login_form'
)
lms/djangoapps/courseware/features/login.py
View file @
4528490f
...
...
@@ -28,9 +28,7 @@ def i_should_see_the_login_error_message(step, msg):
@step
(
u'click the dropdown arrow$'
)
def
click_the_dropdown
(
step
):
css
=
".dropdown"
e
=
world
.
browser
.
find_by_css
(
css
)
e
.
click
()
world
.
css_click
(
'.dropdown'
)
#### helper functions
...
...
lms/djangoapps/courseware/features/openended.py
View file @
4528490f
...
...
@@ -61,8 +61,7 @@ def see_the_grader_status(step, status):
@step
(
'I see the red X$'
)
def
see_the_red_x
(
step
):
x_css
=
'div.grader-status > span.incorrect'
assert
world
.
browser
.
find_by_css
(
x_css
)
assert
world
.
is_css_present
(
'div.grader-status > span.incorrect'
)
@step
(
u'I see the grader score "([^"]*)"$'
)
...
...
@@ -74,8 +73,7 @@ def see_the_grader_score(step, score):
@step
(
'I see the link for full output$'
)
def
see_full_output_link
(
step
):
link_css
=
'a.full'
assert
world
.
browser
.
find_by_css
(
link_css
)
assert
world
.
is_css_present
(
'a.full'
)
@step
(
'I see the spelling grading message "([^"]*)"$'
)
...
...
lms/djangoapps/courseware/features/problems.py
View file @
4528490f
...
...
@@ -339,7 +339,7 @@ def assert_answer_mark(step, problem_type, correctness):
# At least one of the correct selectors should be present
for
sel
in
selector_dict
[
problem_type
]:
has_expected
=
world
.
browser
.
is_element_present_by_css
(
sel
,
wait_time
=
4
)
has_expected
=
world
.
is_css_present
(
sel
)
# As soon as we find the selector, break out of the loop
if
has_expected
:
...
...
@@ -366,7 +366,7 @@ def inputfield(problem_type, choice=None, input_num=1):
# If the input element doesn't exist, fail immediately
assert
(
world
.
browser
.
is_element_present_by_css
(
sel
,
wait_time
=
4
)
)
assert
world
.
is_css_present
(
sel
)
# Retrieve the input element
return
world
.
browser
.
find_by_css
(
sel
)
...
...
lms/djangoapps/courseware/features/registration.py
View file @
4528490f
...
...
@@ -13,17 +13,17 @@ def i_register_for_the_course(step, course):
register_link
=
intro_section
.
find_by_css
(
'a.register'
)
register_link
.
click
()
assert
world
.
browser
.
is_element_present_by_css
(
'section.container.dashboard'
)
assert
world
.
is_css_present
(
'section.container.dashboard'
)
@step
(
u'I should see the course numbered "([^"]*)" in my dashboard$'
)
def
i_should_see_that_course_in_my_dashboard
(
step
,
course
):
course_link_css
=
'section.my-courses a[href*="
%
s"]'
%
course
assert
world
.
browser
.
is_element_present_by_css
(
course_link_css
)
assert
world
.
is_css_present
(
course_link_css
)
@step
(
u'I press the "([^"]*)" button in the Unenroll dialog'
)
def
i_press_the_button_in_the_unenroll_dialog
(
step
,
value
):
button_css
=
'section#unenroll-modal input[value="
%
s"]'
%
value
world
.
browser
.
find_by_css
(
button_css
)
.
click
(
)
assert
world
.
browser
.
is_element_present_by_css
(
'section.container.dashboard'
)
world
.
css_click
(
button_css
)
assert
world
.
is_css_present
(
'section.container.dashboard'
)
lms/djangoapps/courseware/features/signup.py
View file @
4528490f
...
...
@@ -22,4 +22,4 @@ def i_check_checkbox(step, checkbox):
@step
(
'I should see "([^"]*)" in the dashboard banner$'
)
def
i_should_see_text_in_the_dashboard_banner_section
(
step
,
text
):
css_selector
=
"section.dashboard-banner h2"
assert
(
text
in
world
.
browser
.
find_by_css
(
css_selector
)
.
text
)
assert
(
text
in
world
.
css_text
(
css_selector
)
)
lms/djangoapps/courseware/features/smart-accordion.py
View file @
4528490f
...
...
@@ -32,20 +32,20 @@ def i_verify_all_the_content_of_each_course(step):
pass
for
test_course
in
registered_courses
:
test_course
.
find_by_css
(
'a'
)
.
click
(
)
test_course
.
css_click
(
'a'
)
check_for_errors
()
# Get the course. E.g. 'MITx/6.002x/2012_Fall'
current_course
=
sub
(
'/info'
,
''
,
sub
(
'.*/courses/'
,
''
,
world
.
browser
.
url
))
validate_course
(
current_course
,
ids
)
world
.
browser
.
find_link_by_text
(
'Courseware'
)
.
click
(
)
assert
world
.
browser
.
is_element_present_by_id
(
'accordion'
,
wait_time
=
2
)
world
.
click_link
(
'Courseware'
)
assert
world
.
is_css_present
(
'accordion'
)
check_for_errors
()
browse_course
(
current_course
)
# clicking the user link gets you back to the user's home page
world
.
browser
.
find_by_css
(
'.user-link'
)
.
click
(
)
world
.
css_click
(
'.user-link'
)
check_for_errors
()
...
...
@@ -94,7 +94,7 @@ def browse_course(course_id):
world
.
browser
.
find_by_css
(
'#accordion > nav > div'
)[
chapter_it
]
.
find_by_tag
(
'li'
)[
section_it
]
.
find_by_tag
(
'a'
)
.
click
()
## sometimes the course-content takes a long time to load
assert
world
.
browser
.
is_element_present_by_css
(
'.course-content'
,
wait_time
=
5
)
assert
world
.
is_css_present
(
'.course-content'
)
## look for server error div
check_for_errors
()
...
...
lms/djangoapps/courseware/features/xqueue_setup.py
View file @
4528490f
...
...
@@ -3,6 +3,7 @@ from lettuce import before, after, world
from
django.conf
import
settings
import
threading
@before.all
def
setup_mock_xqueue_server
():
...
...
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