From 28c33a4f848c81429a173c7e3c76bc7314e2b89f Mon Sep 17 00:00:00 2001 From: Will Daly Date: Thu, 6 Feb 2014 09:31:21 -0500 Subject: [PATCH] Skip page check in promise for Tab Nav in bok-choy suite --- common/test/acceptance/pages/lms/tab_nav.py | 30 ++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/common/test/acceptance/pages/lms/tab_nav.py b/common/test/acceptance/pages/lms/tab_nav.py index e720f72ce2..2b4e80e3d0 100644 --- a/common/test/acceptance/pages/lms/tab_nav.py +++ b/common/test/acceptance/pages/lms/tab_nav.py @@ -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) )