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
ea8e5f84
Commit
ea8e5f84
authored
Jun 27, 2013
by
JonahStanley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up code
parent
621777e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
64 deletions
+66
-64
cms/djangoapps/contentstore/features/component.feature
+2
-2
cms/djangoapps/contentstore/features/component.py
+64
-62
No files found.
cms/djangoapps/contentstore/features/component.feature
View file @
ea8e5f84
...
@@ -3,7 +3,7 @@ Feature: Component Adding
...
@@ -3,7 +3,7 @@ Feature: Component Adding
Scenario
:
I
can add components
Scenario
:
I
can add components
Given
I have opened a new course in studio
Given
I have opened a new course in studio
And
I am
on
a new unit
And
I am
editing
a new unit
When I add the following components
:
When I add the following components
:
|
Component
|
|
Component
|
|
Discussion
|
|
Discussion
|
...
@@ -46,7 +46,7 @@ Feature: Component Adding
...
@@ -46,7 +46,7 @@ Feature: Component Adding
Scenario
:
I
can delete Components
Scenario
:
I
can delete Components
Given
I have opened a new course in studio
Given
I have opened a new course in studio
And
I am
on
a new unit
And
I am
editing
a new unit
And I add the following components
:
And I add the following components
:
|
Component
|
|
Component
|
|
Discussion
|
|
Discussion
|
...
...
cms/djangoapps/contentstore/features/component.py
View file @
ea8e5f84
...
@@ -3,49 +3,34 @@
...
@@ -3,49 +3,34 @@
from
lettuce
import
world
,
step
from
lettuce
import
world
,
step
data_location
=
'i4x://edx/templates'
DATA_LOCATION
=
'i4x://edx/templates'
@step
(
u'I am
on
a new unit'
)
@step
(
u'I am
editing
a new unit'
)
def
add_unit
(
step
):
def
add_unit
(
step
):
section_css
=
'a.new-courseware-section-button'
css_selectors
=
[
'a.new-courseware-section-button'
,
'input.new-section-name-save'
,
'a.new-subsection-item'
,
'input.new-subsection-name-save'
,
'div.section-item a.expand-collapse-icon'
,
'a.new-unit-item'
]
world
.
css_click
(
section_css
)
for
selector
in
css_selectors
:
save_section_css
=
'input.new-section-name-save'
world
.
css_click
(
selector
)
world
.
css_click
(
save_section_css
)
subsection_css
=
'a.new-subsection-item'
world
.
css_click
(
subsection_css
)
save_subsection_css
=
'input.new-subsection-name-save'
world
.
css_click
(
save_subsection_css
)
expand_css
=
'div.section-item a.expand-collapse-icon'
world
.
css_click
(
expand_css
)
unit_css
=
'a.new-unit-item'
world
.
css_click
(
unit_css
)
@step
(
u'I add the following components:'
)
@step
(
u'I add the following components:'
)
def
add_components
(
step
):
def
add_components
(
step
):
for
component
in
step
.
hashes
:
for
component
in
[
step_hash
[
'Component'
]
for
step_hash
in
step
.
hashes
]:
#due to the way lettuce stores the dictionary
assert
component
in
COMPONENT_DICTIONARY
component
=
component
[
'Component'
]
for
css
in
COMPONENT_DICTIONARY
[
component
][
'steps'
]:
#from pdb import set_trace; set_trace()
assert
component
in
component_dictionary
how_to_add
=
component_dictionary
[
component
][
'steps'
]
for
css
in
how_to_add
:
world
.
css_click
(
css
)
world
.
css_click
(
css
)
@step
(
u'I see the following components'
)
@step
(
u'I see the following components'
)
def
check_components
(
step
):
def
check_components
(
step
):
for
component
in
step
.
hashes
:
for
component
in
[
step_hash
[
'Component'
]
for
step_hash
in
step
.
hashes
]:
component
=
component
[
'Component'
]
assert
component
in
COMPONENT_DICTIONARY
assert
component
in
component_dictionary
assert
COMPONENT_DICTIONARY
[
component
][
'found_func'
]()
assert
component_dictionary
[
component
][
'found'
]()
@step
(
u'I delete all components'
)
@step
(
u'I delete all components'
)
def
delete_all_components
(
step
):
def
delete_all_components
(
step
):
components_num
=
len
(
component_dictionary
)
for
_
in
range
(
len
(
COMPONENT_DICTIONARY
)):
for
delete
in
range
(
0
,
components_num
):
world
.
css_click
(
'a.delete-button'
)
world
.
css_click
(
'a.delete-button'
)
...
@@ -54,73 +39,90 @@ def see_no_components(steps):
...
@@ -54,73 +39,90 @@ def see_no_components(steps):
assert
world
.
is_css_not_present
(
'li.component'
)
assert
world
.
is_css_not_present
(
'li.component'
)
component_dictionary
=
{
def
step_selector_list
(
data_type
,
path
,
index
=
1
):
selector_list
=
[
'a[data-type="{}"]'
.
format
(
data_type
)]
if
index
!=
1
:
selector_list
.
append
(
'a[id="ui-id-{}"]'
.
format
(
index
))
if
path
is
not
None
:
selector_list
.
append
(
'a[data-location="{}/{}/{}"]'
.
format
(
DATA_LOCATION
,
data_type
,
path
))
return
selector_list
def
found_text_func
(
text
):
return
lambda
:
world
.
browser
.
is_text_present
(
text
)
def
found_css_func
(
css
):
return
lambda
:
world
.
is_css_present
(
css
,
wait_time
=
2
)
COMPONENT_DICTIONARY
=
{
'Discussion'
:
{
'Discussion'
:
{
'steps'
:
[
'a[data-type="discussion"]'
]
,
'steps'
:
step_selector_list
(
'discussion'
,
None
)
,
'found
'
:
lambda
:
world
.
is_css_present
(
'section.xmodule_DiscussionModule'
,
wait_time
=
2
)
'found
_func'
:
found_css_func
(
'section.xmodule_DiscussionModule'
)
},
},
'Announcement'
:
{
'Announcement'
:
{
'steps'
:
[
'a[data-type="html"]'
,
'a[data-location="
%
s/html/Announcement"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'html'
,
'Announcement'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'Heading of document'
)
'found
_func'
:
found_text_func
(
'Heading of document'
)
},
},
'Blank HTML'
:
{
'Blank HTML'
:
{
'steps'
:
[
'a[data-type="html"]'
,
'a[data-location="
%
s/html/Blank_HTML_Page"]'
%
data_location
],
'steps'
:
step_selector_list
(
'html'
,
'Blank_HTML_Page'
),
'found'
:
lambda
:
'
\n
\n
'
in
[
x
.
html
for
x
in
world
.
css_find
(
'section.xmodule_HtmlModule'
)]
#this one is a blank html so a more refined search is being done
'found_func'
:
lambda
:
'
\n
\n
'
in
[
x
.
html
for
x
in
world
.
css_find
(
'section.xmodule_HtmlModule'
)]
},
},
'LaTex'
:
{
'LaTex'
:
{
'steps'
:
[
'a[data-type="html"]'
,
'a[data-location="
%
s/html/E-text_Written_in_LaTeX"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'html'
,
'E-text_Written_in_LaTeX'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'EXAMPLE: E-TEXT PAGE'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'EXAMPLE: E-TEXT PAGE'
)
},
},
'Blank Problem'
:
{
'Blank Problem'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[data-location="
%
s/problem/Blank_Common_Problem"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Blank_Common_Problem'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'BLANK COMMON PROBLEM'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'BLANK COMMON PROBLEM'
)
},
},
'Dropdown'
:
{
'Dropdown'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[data-location="
%
s/problem/Dropdown"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Dropdown'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'DROPDOWN'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'DROPDOWN'
)
},
},
'Multi Choice'
:
{
'Multi Choice'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[data-location="
%
s/problem/Multiple_Choice"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Multiple_Choice'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'MULTIPLE CHOICE'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'MULTIPLE CHOICE'
)
},
},
'Numerical'
:
{
'Numerical'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[data-location="
%
s/problem/Numerical_Input"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Numerical_Input'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'NUMERICAL INPUT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'NUMERICAL INPUT'
)
},
},
'Text Input'
:
{
'Text Input'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[data-location="
%
s/problem/Text_Input"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Text_Input'
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'TEXT INPUT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'TEXT INPUT'
)
},
},
'Advanced'
:
{
'Advanced'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Blank_Advanced_Problem"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Blank_Advanced_Problem'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'BLANK ADVANCED PROBLEM'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'BLANK ADVANCED PROBLEM'
)
},
},
'Circuit'
:
{
'Circuit'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Circuit_Schematic_Builder"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Circuit_Schematic_Builder'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'CIRCUIT SCHEMATIC BUILDER'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'CIRCUIT SCHEMATIC BUILDER'
)
},
},
'Custom Python'
:
{
'Custom Python'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Custom_Python-Evaluated_Input"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Custom_Python-Evaluated_Input'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'CUSTOM PYTHON-EVALUATED INPUT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'CUSTOM PYTHON-EVALUATED INPUT'
)
},
},
'Image Mapped'
:
{
'Image Mapped'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Image_Mapped_Input"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Image_Mapped_Input'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'IMAGE MAPPED INPUT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'IMAGE MAPPED INPUT'
)
},
},
'Math Input'
:
{
'Math Input'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Math_Expression_Input"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Math_Expression_Input'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'MATH EXPRESSION INPUT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'MATH EXPRESSION INPUT'
)
},
},
'Problem LaTex'
:
{
'Problem LaTex'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Problem_Written_in_LaTeX"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Problem_Written_in_LaTeX'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'PROBLEM WRITTEN IN LATEX'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'PROBLEM WRITTEN IN LATEX'
)
},
},
'Adaptive Hint'
:
{
'Adaptive Hint'
:
{
'steps'
:
[
'a[data-type="problem"]'
,
'a[id="ui-id-2"]'
,
'a[data-location="
%
s/problem/Problem_with_Adaptive_Hint"]'
%
data_location
]
,
'steps'
:
step_selector_list
(
'problem'
,
'Problem_with_Adaptive_Hint'
,
index
=
2
)
,
'found
'
:
lambda
:
world
.
browser
.
is_text_present
(
'PROBLEM WITH ADAPTIVE HINT'
,
wait_time
=
2
)
'found
_func'
:
found_text_func
(
'PROBLEM WITH ADAPTIVE HINT'
)
},
},
'Video'
:
{
'Video'
:
{
'steps'
:
[
'a[data-type="video"]'
]
,
'steps'
:
step_selector_list
(
'video'
,
None
)
,
'found
'
:
lambda
:
world
.
is_css_present
(
'section.xmodule_VideoModule'
,
wait_time
=
2
)
'found
_func'
:
found_css_func
(
'section.xmodule_VideoModule'
)
}
}
}
}
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