Commit 5092ba6e by E. Kolpakov

Improved test parameters so html contents are now clearly visible

Improved test scenario discovery
parent 522a3c8e
...@@ -16,8 +16,7 @@ class BaseIntegrationTest(SeleniumTest): ...@@ -16,8 +16,7 @@ class BaseIntegrationTest(SeleniumTest):
# Use test scenarios # 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.SCENARIOS.clear()
scenarios_list = load_scenarios_from_path('integration/data') for identifier, title, xml in self._get_scenarios_for_test():
for identifier, title, xml in scenarios_list:
scenarios.add_xml_scenario(identifier, title, xml) scenarios.add_xml_scenario(identifier, title, xml)
self.addCleanup(scenarios.remove_scenario, identifier) self.addCleanup(scenarios.remove_scenario, identifier)
...@@ -28,6 +27,9 @@ class BaseIntegrationTest(SeleniumTest): ...@@ -28,6 +27,9 @@ class BaseIntegrationTest(SeleniumTest):
header1 = self.browser.find_element_by_css_selector('h1') header1 = self.browser.find_element_by_css_selector('h1')
self.assertEqual(header1.text, 'XBlock scenarios') 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'): 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 Navigate to the page `page_name`, as listed on the workbench home
......
...@@ -9,8 +9,8 @@ class TestBlockParameters(BaseIntegrationTest): ...@@ -9,8 +9,8 @@ class TestBlockParameters(BaseIntegrationTest):
@parameterized.expand([ @parameterized.expand([
("plain1", 'title1', 'question1'), ("plain1", 'title1', 'question1'),
("plain2", 'title2', 'question2'), ("plain2", 'title2', 'question2'),
("html1", 'title with <b>HTML</b>', '<span style="color:red">Span title</span>'), ("html1", 'title with <i>HTML</i>', 'Question with <i>HTML</i>'),
("html2", 'Q: <b>HTML</b>?', '<span style="color:red">Span question</span>'), ("html2", '<span style="color:red">Title: HTML?</span>', '<span style="color:red">Span question</span>'),
]) ])
def test_block_parameters(self, _, display_name, question_text): def test_block_parameters(self, _, display_name, question_text):
const_page_name = "Test block parameters" const_page_name = "Test block parameters"
...@@ -32,3 +32,8 @@ class TestBlockParameters(BaseIntegrationTest): ...@@ -32,3 +32,8 @@ class TestBlockParameters(BaseIntegrationTest):
question = page.find_element_by_css_selector("section.problem > p") question = page.find_element_by_css_selector("section.problem > p")
self.assertEqual(self.get_element_html(question), question_text) 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): ...@@ -38,11 +38,7 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False):
for template in os.listdir(scenarios_fullpath): for template in os.listdir(scenarios_fullpath):
if not template.endswith('.json'): if not template.endswith('.json'):
continue continue
identifier = template[:-5] identifier, title, scenario = get_scenario_from_file(template, scenarios_path)
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)
if not include_identifier: if not include_identifier:
scenarios.append((title, scenario)) scenarios.append((title, scenario))
else: else:
...@@ -51,6 +47,15 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False): ...@@ -51,6 +47,15 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False):
return scenarios 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): def load_scenarios_from_path(scenarios_path):
""" """
Load all xml files contained in a specified directory, as workbench scenarios 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