Commit 5092ba6e by E. Kolpakov

Improved test parameters so html contents are now clearly visible

Improved test scenario discovery
parent 522a3c8e
......@@ -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
......
......@@ -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 []
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment