Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
OpenEdx
xblock-drag-and-drop-v2
Commits
5092ba6e
Commit
5092ba6e
authored
Sep 29, 2014
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved test parameters so html contents are now clearly visible
Improved test scenario discovery
parent
522a3c8e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
tests/integration/test_base.py
+5
-3
tests/integration/test_block_parameters.py
+7
-2
tests/utils.py
+10
-5
No files found.
tests/integration/test_base.py
View file @
5092ba6e
...
...
@@ -14,10 +14,9 @@ class BaseIntegrationTest(SeleniumTest):
super
(
BaseIntegrationTest
,
self
)
.
setUp
()
# Use test scenarios
self
.
browser
.
get
(
self
.
live_server_url
)
# Needed to load tests once
self
.
browser
.
get
(
self
.
live_server_url
)
# Needed to load tests once
scenarios
.
SCENARIOS
.
clear
()
scenarios_list
=
load_scenarios_from_path
(
'integration/data'
)
for
identifier
,
title
,
xml
in
scenarios_list
:
for
identifier
,
title
,
xml
in
self
.
_get_scenarios_for_test
():
scenarios
.
add_xml_scenario
(
identifier
,
title
,
xml
)
self
.
addCleanup
(
scenarios
.
remove_scenario
,
identifier
)
...
...
@@ -28,6 +27,9 @@ class BaseIntegrationTest(SeleniumTest):
header1
=
self
.
browser
.
find_element_by_css_selector
(
'h1'
)
self
.
assertEqual
(
header1
.
text
,
'XBlock scenarios'
)
def
_get_scenarios_for_test
(
self
):
return
load_scenarios_from_path
(
'integration/data'
)
def
go_to_page
(
self
,
page_name
,
css_selector
=
'section.xblock--drag-and-drop'
):
"""
Navigate to the page `page_name`, as listed on the workbench home
...
...
tests/integration/test_block_parameters.py
View file @
5092ba6e
...
...
@@ -9,8 +9,8 @@ class TestBlockParameters(BaseIntegrationTest):
@parameterized.expand
([
(
"plain1"
,
'title1'
,
'question1'
),
(
"plain2"
,
'title2'
,
'question2'
),
(
"html1"
,
'title with <
b>HTML</b>'
,
'<span style="color:red">Span title</span
>'
),
(
"html2"
,
'
Q: <b>HTML</b>?
'
,
'<span style="color:red">Span question</span>'
),
(
"html1"
,
'title with <
i>HTML</i>'
,
'Question with <i>HTML</i
>'
),
(
"html2"
,
'
<span style="color:red">Title: HTML?</span>
'
,
'<span style="color:red">Span question</span>'
),
])
def
test_block_parameters
(
self
,
_
,
display_name
,
question_text
):
const_page_name
=
"Test block parameters"
...
...
@@ -32,3 +32,8 @@ class TestBlockParameters(BaseIntegrationTest):
question
=
page
.
find_element_by_css_selector
(
"section.problem > p"
)
self
.
assertEqual
(
self
.
get_element_html
(
question
),
question_text
)
def
_get_scenarios_for_test
(
self
):
return
[]
tests/utils.py
View file @
5092ba6e
...
...
@@ -38,11 +38,7 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False):
for
template
in
os
.
listdir
(
scenarios_fullpath
):
if
not
template
.
endswith
(
'.json'
):
continue
identifier
=
template
[:
-
5
]
block_title
,
question_text
=
map
(
format_name
,
identifier
.
split
(
'-'
))
title
=
identifier
.
replace
(
'_'
,
' '
)
.
replace
(
'-'
,
' '
)
.
title
()
template_path
=
os
.
path
.
join
(
scenarios_path
,
template
)
scenario
=
make_scenario_from_data
(
load_resource
(
template_path
),
block_title
,
question_text
,
False
)
identifier
,
title
,
scenario
=
get_scenario_from_file
(
template
,
scenarios_path
)
if
not
include_identifier
:
scenarios
.
append
((
title
,
scenario
))
else
:
...
...
@@ -51,6 +47,15 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False):
return
scenarios
def
get_scenario_from_file
(
filename
,
scenarios_path
):
identifier
=
filename
[:
-
5
]
block_title
,
question_text
=
map
(
format_name
,
identifier
.
split
(
'-'
))
title
=
identifier
.
replace
(
'_'
,
' '
)
.
replace
(
'-'
,
' '
)
.
title
()
scenario_file
=
os
.
path
.
join
(
scenarios_path
,
filename
)
scenario
=
make_scenario_from_data
(
scenario_file
,
block_title
,
question_text
,
False
)
return
identifier
,
title
,
scenario
def
load_scenarios_from_path
(
scenarios_path
):
"""
Load all xml files contained in a specified directory, as workbench scenarios
...
...
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