Commit 2b45e10f by E. Kolpakov

Bok choy acceptance tests

parent e06b6fea
......@@ -35,8 +35,10 @@ def enum(**enums):
def _get_capa_types():
"""
Gets capa types tags and labels
"""
capa_types = {
ANY_CAPA_TYPE_VALUE: _('Any Type'),
'annotationinput': _('Annotation'),
'checkboxgroup': _('Checkbox Group'),
'checkboxtextgroup': _('Checkbox Text Group'),
......@@ -54,7 +56,7 @@ def _get_capa_types():
'javascriptinput': _('Javascript Input'),
'jsinput': _('JS Input'),
'matlabinput': _('Matlab'),
'optioninput': _('Select option'),
'optioninput': _('Select Option'),
'radiogroup': _('Radio Group'),
'radiotextgroup': _('Radio Text Group'),
'schematic': _('Schematic'),
......@@ -63,7 +65,7 @@ def _get_capa_types():
'vsepr_input': _('VSEPR'),
}
return sorted([
return [{'value': ANY_CAPA_TYPE_VALUE, 'display_name': _('Any Type')}] + sorted([
{'value': capa_type, 'display_name': caption}
for capa_type, caption in capa_types.items()
], key=lambda item: item.get('display_name'))
......@@ -221,6 +223,9 @@ class LibraryContentModule(LibraryContentFields, XModule, StudioEditableModule):
any particular student.
"""
def _filter_children(self, child_locator):
"""
Filters children by CAPA problem type, if configured
"""
if self.capa_type == ANY_CAPA_TYPE_VALUE:
return True
......@@ -234,7 +239,6 @@ class LibraryContentModule(LibraryContentFields, XModule, StudioEditableModule):
return any(self.capa_type in capa_input.tags for capa_input in block.lcp.inputs.values())
def selected_children(self):
"""
Returns a set() of block_ids indicating which of the possible children
......@@ -427,8 +431,8 @@ class LibraryContentDescriptor(LibraryContentFields, MakoModuleDescriptor, XmlDe
If source_libraries has been edited, refresh_children automatically.
"""
old_source_libraries = LibraryList().from_json(old_metadata.get('source_libraries', []))
if (set(old_source_libraries) != set(self.source_libraries) or
old_metadata.get('capa_type', ANY_CAPA_TYPE_VALUE) != self.capa_type):
if set(old_source_libraries) != set(self.source_libraries) or \
old_metadata.get('capa_type', ANY_CAPA_TYPE_VALUE) != self.capa_type:
try:
self.refresh_children(None, None, update_db=False) # update_db=False since update_item() is about to be called anyways
except ValueError:
......
......@@ -16,6 +16,9 @@ class LibraryContentXBlockWrapper(PageObject):
self.locator = locator
def is_browser_on_page(self):
"""
Checks if page is opened
"""
return self.q(css='{}[data-id="{}"]'.format(self.BODY_SELECTOR, self.locator)).present
def _bounded_selector(self, selector):
......@@ -35,3 +38,11 @@ class LibraryContentXBlockWrapper(PageObject):
"""
child_blocks = self.q(css=self._bounded_selector("div[data-id]"))
return frozenset(child.text for child in child_blocks)
@property
def children_headers(self):
"""
Gets headers if all child XBlocks as list of strings
"""
child_blocks_headers = self.q(css=self._bounded_selector("div[data-id] h2.problem-header"))
return frozenset(child.text for child in child_blocks_headers)
......@@ -122,6 +122,7 @@ class StudioLibraryContentXBlockEditModal(CourseOutlineModal, PageObject):
LIBRARY_LABEL = "Libraries"
COUNT_LABEL = "Count"
SCORED_LABEL = "Scored"
PROBLEM_TYPE_LABEL = "Problem Type"
def is_browser_on_page(self):
"""
......@@ -196,6 +197,24 @@ class StudioLibraryContentXBlockEditModal(CourseOutlineModal, PageObject):
scored_select.select_by_value(str(scored))
EmptyPromise(lambda: self.scored == scored, "scored is updated in modal.").fulfill()
@property
def capa_type(self):
"""
Gets value of CAPA type select
"""
return self.get_metadata_input(self.PROBLEM_TYPE_LABEL).get_attribute('value')
@capa_type.setter
def capa_type(self, value):
"""
Sets value of CAPA type select
"""
select_element = self.get_metadata_input(self.PROBLEM_TYPE_LABEL)
select_element.click()
problem_type_select = Select(select_element)
problem_type_select.select_by_value(value)
EmptyPromise(lambda: self.capa_type == value, "problem type is updated in modal.").fulfill()
def _add_library_key(self):
"""
Adds library key input
......
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