Merge pull request #2492 from edx/will/really-fix-tab-nav-test

Skip page check in promise for Tab Nav in bok-choy suite
This commit is contained in:
Will Daly
2014-02-06 10:22:50 -05:00

View File

@@ -36,15 +36,10 @@ class TabNavPage(PageObject):
def is_on_tab(self, tab_name):
"""
Return a boolean indicating whether the current tab is `tab_name`.
Because this is a public method, it checks that we're on the right page
before accessing the DOM.
"""
current_tab_list = self.css_text('ol.course-tabs>li>a.active')
if len(current_tab_list) == 0:
self.warning("Could not find current tab")
return False
else:
return (current_tab_list[0].strip().split('\n')[0] == tab_name)
return self._is_on_tab(tab_name)
def _tab_css(self, tab_name):
"""
@@ -73,11 +68,28 @@ class TabNavPage(PageObject):
return fulfill(Promise(_check_func, "Get all tab names"))
def _is_on_tab(self, tab_name):
"""
Return a boolean indicating whether the current tab is `tab_name`.
This is a private method, so it does NOT enforce the page check,
which is what we want when we're polling the DOM in a promise.
"""
current_tab_list = self.css_text('ol.course-tabs>li>a.active')
if len(current_tab_list) == 0:
self.warning("Could not find current tab")
return False
else:
return (current_tab_list[0].strip().split('\n')[0] == tab_name)
def _is_on_tab_promise(self, tab_name):
"""
Return a `Promise` that the user is on the tab `tab_name`.
"""
# Use the private version of _is_on_tab to skip the page check
return EmptyPromise(
lambda: self.is_on_tab(tab_name),
lambda: self._is_on_tab(tab_name),
"{0} is the current tab".format(tab_name)
)