Commit a7717ea8 by Xavier Antoviaque

light-children: Fix tests runner

parent b970de42
...@@ -33,7 +33,12 @@ from django.core.urlresolvers import reverse ...@@ -33,7 +33,12 @@ from django.core.urlresolvers import reverse
from xblock.core import XBlock from xblock.core import XBlock
from xblock.fragment import Fragment from xblock.fragment import Fragment
from xblock.plugin import Plugin from xblock.plugin import Plugin
from xmodule_modifiers import replace_jump_to_id_urls
try:
from xmodule_modifiers import replace_jump_to_id_urls
except:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
replace_jump_to_id_urls = lambda a,b,c,d,frag,f: frag
from .utils import XBlockWithChildrenFragmentsMixin from .utils import XBlockWithChildrenFragmentsMixin
...@@ -162,17 +167,21 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock): ...@@ -162,17 +167,21 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
Current HTML view of the XBlock, for refresh by client Current HTML view of the XBlock, for refresh by client
""" """
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`? # TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
course_id = self.xmodule_runtime.course_id try:
course_id = self.xmodule_runtime.course_id
except AttributeError:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
course_id = 'sample-course'
try:
jump_to_url = reverse('jump_to_id', kwargs={'course_id': course_id, 'module_id': ''})
except:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
jump_to_url = '/jump_to_id'
frag = self.student_view({}) frag = self.student_view({})
frag = replace_jump_to_id_urls( frag = replace_jump_to_id_urls(course_id, jump_to_url, self, 'student_view', frag, {})
course_id,
reverse('jump_to_id', kwargs={'course_id': course_id, 'module_id': ''}),
self,
'student_view',
frag,
{}
)
return { return {
'html': frag.content, 'html': frag.content,
} }
...@@ -194,7 +203,15 @@ class LightChild(Plugin, LightChildrenMixin): ...@@ -194,7 +203,15 @@ class LightChild(Plugin, LightChildrenMixin):
@property @property
def xmodule_runtime(self): def xmodule_runtime(self):
return self.parent.xmodule_runtime try:
xmodule_runtime = self.parent.xmodule_runtime
except AttributeError:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
class xmodule_runtime(object):
course_id = 'sample-course'
anonymous_student_id = 'student1'
xmodule_runtime = xmodule_runtime()
return xmodule_runtime
def save(self): def save(self):
pass pass
......
...@@ -39,7 +39,7 @@ class MentoringBaseTest(SeleniumTest): ...@@ -39,7 +39,7 @@ class MentoringBaseTest(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('tests/xml') scenarios_list = load_scenarios_from_path('../tests/xml')
for identifier, title, xml in scenarios_list: for identifier, title, xml in scenarios_list:
self.addCleanup(scenarios.remove_scenario, identifier) self.addCleanup(scenarios.remove_scenario, identifier)
......
...@@ -71,8 +71,9 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False): ...@@ -71,8 +71,9 @@ def get_scenarios_from_path(scenarios_path, include_identifier=False):
Returns an array of (title, xmlcontent) from files contained in a specified directory, Returns an array of (title, xmlcontent) from files contained in a specified directory,
formatted as expected for the return value of the workbench_scenarios() method formatted as expected for the return value of the workbench_scenarios() method
""" """
base_fullpath = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) base_fullpath = os.path.dirname(os.path.realpath(__file__))
scenarios_fullpath = os.path.join(base_fullpath, scenarios_path) scenarios_fullpath = os.path.join(base_fullpath, scenarios_path)
print scenarios_fullpath
scenarios = [] scenarios = []
if os.path.isdir(scenarios_fullpath): if os.path.isdir(scenarios_fullpath):
......
<vertical> <vertical>
<mentoring-table type="table_test" url_name="table_2"> <mentoring display_submit="false" enforce_dependency="false">
<column> <mentoring-table type="table_test" url_name="table_2">
<header>Header Test 1</header> <column>
<answer name="table_1_answer_1" /> <header>Header Test 1</header>
</column> <answer name="table_1_answer_1" />
</column>
<column> <column>
<header>Header Test 2</header> <header>Header Test 2</header>
<answer name="table_1_answer_2" /> <answer name="table_1_answer_2" />
</column> </column>
</mentoring-table> </mentoring-table>
</mentoring>
</vertical> </vertical>
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