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
38632c52
Commit
38632c52
authored
Feb 14, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Beginnings of Selenium test.
parent
ff0b85ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
9 deletions
+136
-9
cms/djangoapps/contentstore/features/advanced-settings.feature
+25
-0
cms/djangoapps/contentstore/features/advanced-settings.py
+91
-0
cms/djangoapps/contentstore/features/common.py
+20
-3
cms/djangoapps/contentstore/features/section.py
+0
-6
No files found.
cms/djangoapps/contentstore/features/advanced-settings.feature
0 → 100644
View file @
38632c52
Feature
:
Advanced (manual) course policy
In order to specify course policy settings for which no custom user interface exists
I want to be able to manually enter JSON key/value pairs
Scenario
:
A
course author sees only display_name on a newly created course
Given
I have opened a new course in Studio
When
I select the Advanced Settings
Then
I see only the display name
Scenario
:
A
course author sees something sensible if there are no policy settings without existing UI controls
Given
I have opened a new course in Studio
When
I select the Advanced Settings
And
I delete the display name
Then
There are no advanced policy settings
And
I refresh and select the Advanced Settings
Then
There are no advanced policy settings
Scenario
:
A
course author can add new entries, and they appear alphabetically after save
Given
I have opened a new course in Studio
When
I select the Advanced Settings
And
Create New Entries
Then
They are alphabetized
And
I refresh and select the Advanced Settings
Then
They are alphabetized
\ No newline at end of file
cms/djangoapps/contentstore/features/advanced-settings.py
0 → 100644
View file @
38632c52
from
lettuce
import
world
,
step
from
common
import
*
import
time
from
nose.tools
import
assert_equal
from
nose.tools
import
assert_true
from
selenium.webdriver.common.keys
import
Keys
############### ACTIONS ####################
@step
(
'I select the Advanced Settings$'
)
def
i_select_advanced_settings
(
step
):
link_css
=
'a#settings-tab'
css_click
(
link_css
)
link_css
=
"[data-section='advanced']"
css_click
(
link_css
)
@step
(
'I refresh and select the Advanced Settings$'
)
def
refresh_and_select_advanced_settings
(
step
):
reload
()
i_select_advanced_settings
(
step
)
@step
(
'I see only the display name$'
)
def
i_see_only_display_name
(
step
):
assert_policy_entries
([
"display_name"
],
[
'"Robot Super Course"'
])
@step
(
'I delete the display name'
)
def
i_delete_the_display_name
(
step
):
delete_entry
(
0
)
click_save
()
@step
(
"There are no advanced policy settings$"
)
def
no_policy_settings
(
step
):
assert_policy_entries
([],
[])
@step
(
"Create New Entries"
)
def
create_new_entries
(
step
):
create_entry
(
"z"
,
"apple"
)
create_entry
(
"a"
,
"zebra"
)
click_save
()
@step
(
"They are alphabetized"
)
def
they_are_alphabetized
(
step
):
assert_policy_entries
([
"a"
,
"display_name"
,
"z"
],
[
'"zebra"'
,
'"Robot Super Course"'
,
'"apple"'
])
def
create_entry
(
key
,
value
):
css_click
(
".new-advanced-policy-item"
)
newKey
=
css_find
(
'#__new_advanced_key__ input'
)
.
first
newKey
.
fill
(
key
)
# For some reason have to get the instance for each command (get error that it is no longer attached to the DOM)
# Have to do all this because Selenium has a bug that fill does not remove existing text
css_find
(
'.CodeMirror textarea'
)
.
last
.
double_click
()
css_find
(
'.CodeMirror textarea'
)
.
last
.
_element
.
send_keys
(
Keys
.
ARROW_LEFT
)
css_find
(
'.CodeMirror textarea'
)
.
last
.
fill
(
value
)
def
delete_entry
(
index
):
""" index is 0-based
"""
css
=
'.delete-button'
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
delete_buttons
=
css_find
(
css
)
assert_true
(
len
(
delete_buttons
)
>
index
,
"no delete button exists for entry "
+
str
(
index
))
delete_buttons
[
index
]
.
click
()
def
assert_policy_entries
(
expected_keys
,
expected_values
):
assert_entries
(
'.key input'
,
expected_keys
)
assert_entries
(
'.json'
,
expected_values
)
def
assert_entries
(
css
,
expected_values
):
webElements
=
css_find
(
css
)
assert_equal
(
len
(
expected_values
),
len
(
webElements
))
# Sometimes get stale reference if I hold on to the array of elements
for
counter
in
range
(
len
(
expected_values
)):
assert_equal
(
expected_values
[
counter
],
css_find
(
css
)[
counter
]
.
value
)
def
click_save
():
css
=
".save-button"
def
is_shown
(
driver
):
visible
=
css_find
(
css
)
.
first
.
visible
if
visible
:
# Even when waiting for visible, this fails sporadically. Adding in a small wait.
time
.
sleep
(
float
(
1
))
return
visible
wait_for
(
is_shown
)
css_click
(
css
)
def
fill_last_field
(
value
):
newValue
=
css_find
(
'#__new_advanced_key__ input'
)
.
first
newValue
.
fill
(
value
)
\ No newline at end of file
cms/djangoapps/contentstore/features/common.py
View file @
38632c52
from
lettuce
import
world
,
step
from
factories
import
*
from
django.core.management
import
call_command
from
lettuce.django
import
django_url
from
django.conf
import
settings
from
django.core.management
import
call_command
from
nose.tools
import
assert_true
from
nose.tools
import
assert_equal
import
xmodule.modulestore.django
from
selenium.webdriver.support.ui
import
WebDriverWait
from
logging
import
getLogger
logger
=
getLogger
(
__name__
)
...
...
@@ -38,6 +36,12 @@ def i_press_the_category_delete_icon(step, category):
assert
False
,
'Invalid category:
%
s'
%
category
css_click
(
css
)
@step
(
'I have opened a new course in Studio$'
)
def
i_have_opened_a_new_course
(
step
):
clear_courses
()
log_into_studio
()
create_a_course
()
####### HELPER FUNCTIONS ##############
def
create_studio_user
(
uname
=
'robot'
,
...
...
@@ -75,11 +79,24 @@ def assert_css_with_text(css,text):
assert_equal
(
world
.
browser
.
find_by_css
(
css
)
.
text
,
text
)
def
css_click
(
css
):
assert_true
(
world
.
browser
.
is_element_present_by_css
(
css
,
5
))
world
.
browser
.
find_by_css
(
css
)
.
first
.
click
()
def
css_fill
(
css
,
value
):
world
.
browser
.
find_by_css
(
css
)
.
first
.
fill
(
value
)
def
css_find
(
css
):
return
world
.
browser
.
find_by_css
(
css
)
def
wait_for
(
func
):
WebDriverWait
(
world
.
browser
.
driver
,
10
)
.
until
(
func
)
def
id_find
(
id
):
return
world
.
browser
.
find_by_id
(
id
)
def
reload
():
return
world
.
browser
.
reload
()
def
clear_courses
():
flush_xmodule_store
()
...
...
cms/djangoapps/contentstore/features/section.py
View file @
38632c52
...
...
@@ -2,12 +2,6 @@ from lettuce import world, step
from
common
import
*
############### ACTIONS ####################
@step
(
'I have opened a new course in Studio$'
)
def
i_have_opened_a_new_course
(
step
):
clear_courses
()
log_into_studio
()
create_a_course
()
@step
(
'I click the new section link$'
)
def
i_click_new_section_link
(
step
):
link_css
=
'a.new-courseware-section-button'
...
...
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