Beispiel #1
0
 def start_response_edit(self, response_id):
     """Click the edit button for the response, loading the editing view"""
     self.css_click(".response_{} .discussion-response .action-edit".format(
         response_id))
     fulfill(
         EmptyPromise(lambda: self.is_response_editor_visible(response_id),
                      "Response edit started"))
 def load_more_responses(self):
     """Clicks the laod more responses button and waits for responses to load"""
     self.css_click(".load-response-button")
     fulfill(EmptyPromise(
         lambda: not self.is_css_present(".loading"),
         "Loading more responses completed"
     ))
 def start_response_edit(self, response_id):
     """Click the edit button for the response, loading the editing view"""
     self.css_click(".response_{} .discussion-response .action-edit".format(response_id))
     fulfill(EmptyPromise(
         lambda: self.is_response_editor_visible(response_id),
         "Response edit started"
     ))
 def delete_comment(self, comment_id):
     with self.handle_alert():
         self.css_click("#comment_{} div.action-delete".format(comment_id))
     fulfill(EmptyPromise(
         lambda: not self.is_comment_visible(comment_id),
         "Deleted comment was removed"
     ))
 def load_more_responses(self):
     """Clicks the laod more responses button and waits for responses to load"""
     self.css_click(".load-response-button")
     fulfill(EmptyPromise(
         lambda: not self.is_css_present(".loading"),
         "Loading more responses completed"
     ))
Beispiel #6
0
 def cancel_comment_edit(self, comment_id, original_body):
     """Click the cancel button on the comment editor"""
     self.css_click("#comment_{} .post-cancel".format(comment_id))
     fulfill(
         EmptyPromise(
             lambda: (not self.is_comment_editor_visible(
                 comment_id) and self.is_comment_visible(comment_id) and
                      self.get_comment_body(comment_id) == original_body),
             "Comment edit was canceled"))
Beispiel #7
0
 def submit_comment_edit(self, comment_id):
     """Click the submit button on the comment editor"""
     new_body = self._get_comment_editor_value(comment_id)
     self.css_click("#comment_{} .post-update".format(comment_id))
     fulfill(
         EmptyPromise(
             lambda: (not self.is_comment_editor_visible(
                 comment_id) and self.is_comment_visible(comment_id) and
                      self.get_comment_body(comment_id) == new_body),
             "Comment edit succeeded"))
Beispiel #8
0
 def start_comment_edit(self, comment_id):
     """Click the edit button for the comment, loading the editing view"""
     old_body = self.get_comment_body(comment_id)
     self.css_click("#comment_{} .action-edit".format(comment_id))
     fulfill(
         EmptyPromise(
             lambda: (self.is_comment_editor_visible(comment_id) and
                      not self.is_comment_visible(comment_id) and self.
                      _get_comment_editor_value(comment_id) == old_body),
             "Comment edit started"))
 def click_add_response_button(self):
     """
     Clicks the add response button and ensures that the response text
     field receives focus
     """
     self.css_click(".add-response-btn")
     fulfill(EmptyPromise(
         lambda: self.is_css_present("#wmd-input-reply-body-{thread_id}:focus".format(thread_id=self.thread_id)),
         "Response field received focus"
     ))
 def click_add_response_button(self):
     """
     Clicks the add response button and ensures that the response text
     field receives focus
     """
     self.css_click(".add-response-btn")
     fulfill(EmptyPromise(
         lambda: self.is_css_present("#wmd-input-reply-body-{thread_id}:focus".format(thread_id=self.thread_id)),
         "Response field received focus"
     ))
Beispiel #11
0
 def edit(self):
     self.css_click(self._bounded_selector('.edit-button'))
     fulfill(
         EmptyPromise(
             lambda: all(
                 self.q(css=self._bounded_selector('.component-editor')).
                 map(lambda el: el.visible).results),
             "Verify that the editor for component {} has been expanded".
             format(self.locator)))
     return self
Beispiel #12
0
 def edit_draft(self):
     """
     Started editing a draft of this unit.
     """
     fulfill(
         EmptyPromise(lambda: self.q(css='.create-draft').present,
                      'Wait for edit draft link to be present'))
     self.q(css='.create-draft').click()
     fulfill(
         EmptyPromise(lambda: self.q(css='.editing-draft-alert').present,
                      'Wait for draft mode to be activated'))
Beispiel #13
0
 def edit(self):
     self.css_click(self._bounded_selector('.edit-button'))
     fulfill(EmptyPromise(
         lambda: all(
             self.q(css=self._bounded_selector('.component-editor'))
                 .map(lambda el: el.visible)
                 .results
             ),
         "Verify that the editor for component {} has been expanded".format(self.locator)
     ))
     return self
 def cancel_comment_edit(self, comment_id, original_body):
     """Click the cancel button on the comment editor"""
     self.css_click("#comment_{} .post-cancel".format(comment_id))
     fulfill(EmptyPromise(
         lambda: (
             not self.is_comment_editor_visible(comment_id) and
             self.is_comment_visible(comment_id) and
             self.get_comment_body(comment_id) == original_body
         ),
         "Comment edit was canceled"
     ))
 def submit_comment_edit(self, comment_id):
     """Click the submit button on the comment editor"""
     new_body = self._get_comment_editor_value(comment_id)
     self.css_click("#comment_{} .post-update".format(comment_id))
     fulfill(EmptyPromise(
         lambda: (
             not self.is_comment_editor_visible(comment_id) and
             self.is_comment_visible(comment_id) and
             self.get_comment_body(comment_id) == new_body
         ),
         "Comment edit succeeded"
     ))
 def start_comment_edit(self, comment_id):
     """Click the edit button for the comment, loading the editing view"""
     old_body = self.get_comment_body(comment_id)
     self.css_click("#comment_{} .action-edit".format(comment_id))
     fulfill(EmptyPromise(
         lambda: (
             self.is_comment_editor_visible(comment_id) and
             not self.is_comment_visible(comment_id) and
             self._get_comment_editor_value(comment_id) == old_body
         ),
         "Comment edit started"
     ))
Beispiel #17
0
 def edit_draft(self):
     """
     Started editing a draft of this unit.
     """
     fulfill(EmptyPromise(
         lambda: self.q(css='.create-draft').present,
         'Wait for edit draft link to be present'
     ))
     self.q(css='.create-draft').click()
     fulfill(EmptyPromise(
         lambda: self.q(css='.editing-draft-alert').present,
         'Wait for draft mode to be activated'
     ))
    def _wait_for_submitted(self, assessment_type):
        """
        Wait for the submission to complete.
        `assessment_type` is either 'self', 'ai', or 'peer'
        """
        if assessment_type == 'self':
            RubricPage(self.browser).wait_for_page()

        elif assessment_type == 'ai' or assessment_type == "peer":
            fulfill(
                EmptyPromise(lambda: self.grader_status != 'Unanswered',
                             "Problem status is no longer 'unanswered'"))

        else:
            self.warning(
                "Unrecognized assessment type '{0}'".format(assessment_type))
            fulfill(EmptyPromise(lambda: True, "Unrecognized assessment type"))
    def _wait_for_submitted(self, assessment_type):
        """
        Wait for the submission to complete.
        `assessment_type` is either 'self', 'ai', or 'peer'
        """
        if assessment_type == 'self':
            RubricPage(self.browser).wait_for_page()

        elif assessment_type == 'ai' or assessment_type == "peer":
            fulfill(EmptyPromise(
                lambda: self.grader_status != 'Unanswered',
                "Problem status is no longer 'unanswered'"
            ))

        else:
            self.warning("Unrecognized assessment type '{0}'".format(assessment_type))
            fulfill(EmptyPromise(lambda: True, "Unrecognized assessment type"))
Beispiel #20
0
    def test_change_lang(self):
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
        self.dashboard_page.visit()
        # Change language to Dummy Esperanto
        self.dashboard_page.change_language(self.test_new_lang)

        changed_text = fulfill(self._changed_lang_promise)
        # We should see the dummy-language text on the page
        self.assertIn(self.current_courses_text, changed_text)
Beispiel #21
0
    def test_change_lang(self):
        AutoAuthPage(self.browser, course_id=self.course_id).visit()
        self.dashboard_page.visit()
        # Change language to Dummy Esperanto
        self.dashboard_page.change_language(self.test_new_lang)

        changed_text = fulfill(self._changed_lang_promise)
        # We should see the dummy-language text on the page
        self.assertIn(self.current_courses_text, changed_text)
Beispiel #22
0
    def make_broken_promise(self):
        """
        Make a promise that will not be fulfilled.
        Should raise a `BrokenPromise` exception.
        """
        bad_promise = EmptyPromise(
            lambda: self.is_css_present('div#not_present'), "Invalid div appeared",
            try_limit=3, try_interval=0.01
        )

        return fulfill(bad_promise)
Beispiel #23
0
    def _tab_names(self):
        """
        Return the list of available tab names.  If no tab names
        are available, wait for them to load.  Raises a `BrokenPromiseError`
        if the tab names fail to load.
        """
        def _check_func():
            tab_names = self.css_text('ol.course-tabs li a')
            return (len(tab_names) > 0, tab_names)

        return fulfill(Promise(_check_func, "Get all tab names"))
Beispiel #24
0
 def get_asynch_feedback(self, assessment_type):
     """
     Wait for and retrieve asynchronous feedback
     (e.g. from AI, instructor, or peer grading)
     `assessment_type` is either "ai" or "peer".
     """
     feedback_promise = Promise(
         self._check_feedback_func(assessment_type),
         'Got feedback for {0} problem'.format(assessment_type)
     )
     return fulfill(feedback_promise)
Beispiel #25
0
    def _tab_names(self):
        """
        Return the list of available tab names.  If no tab names
        are available, wait for them to load.  Raises a `BrokenPromiseError`
        if the tab names fail to load.
        """
        def _check_func():
            tab_names = self.css_text('ol.course-tabs li a')
            return (len(tab_names) > 0, tab_names)

        return fulfill(Promise(_check_func, "Get all tab names"))
Beispiel #26
0
    def toggle_expand(self):
        """
        Toggle the expansion of this subsection.
        """
        self.disable_jquery_animations()

        def subsection_expanded():
            return all(
                self.q(css=self._bounded_selector('.new-unit-item')).map(
                    lambda el: el.visible).results)

        currently_expanded = subsection_expanded()

        self.css_click(self._bounded_selector('.expand-collapse'))
        fulfill(
            EmptyPromise(
                lambda: subsection_expanded() != currently_expanded,
                "Check that the subsection {} has been toggled".format(
                    self.locator),
            ))
        return self
Beispiel #27
0
    def toggle_expand(self):
        """
        Toggle the expansion of this subsection.
        """
        self.disable_jquery_animations()

        def subsection_expanded():
            return all(
                self.q(css=self._bounded_selector('.new-unit-item'))
                    .map(lambda el: el.visible)
                    .results
            )

        currently_expanded = subsection_expanded()

        self.css_click(self._bounded_selector('.expand-collapse'))
        fulfill(EmptyPromise(
            lambda: subsection_expanded() != currently_expanded,
            "Check that the subsection {} has been toggled".format(self.locator),
        ))
        return self
Beispiel #28
0
 def get_asynch_feedback(self, assessment_type):
     """
     Wait for and retrieve asynchronous feedback
     (e.g. from AI, instructor, or peer grading)
     `assessment_type` is either "ai" or "peer".
     """
     # Because the check function involves fairly complicated actions
     # (navigating through several screens), we give it more time to complete
     # than the default.
     feedback_promise = Promise(
         self._check_feedback_func(assessment_type),
         'Got feedback for {0} problem'.format(assessment_type),
         timeout=600, try_interval=5
     )
     return fulfill(feedback_promise)
Beispiel #29
0
 def get_asynch_feedback(self, assessment_type):
     """
     Wait for and retrieve asynchronous feedback
     (e.g. from AI, instructor, or peer grading)
     `assessment_type` is either "ai" or "peer".
     """
     # Because the check function involves fairly complicated actions
     # (navigating through several screens), we give it more time to complete
     # than the default.
     feedback_promise = Promise(
         self._check_feedback_func(assessment_type),
         'Got feedback for {0} problem'.format(assessment_type),
         timeout=600,
         try_interval=5)
     return fulfill(feedback_promise)
Beispiel #30
0
    def assert_course_available(self, course_id):
        # Occassionally this does not show up immediately,
        # so we wait and try reloading the page
        def _check_course_available():
            available = self.find_courses_page.course_id_list
            if course_id in available:
                return True
            else:
                self.find_courses_page.visit()
                return False

        return fulfill(EmptyPromise(
            _check_course_available,
            "Found course {course_id} in the list of available courses".format(course_id=course_id),
            try_limit=3, try_interval=2
        ))
Beispiel #31
0
    def assert_course_available(self, course_id):
        # Occassionally this does not show up immediately,
        # so we wait and try reloading the page
        def _check_course_available():
            available = self.find_courses_page.course_id_list
            if course_id in available:
                return True
            else:
                self.find_courses_page.visit()
                return False

        return fulfill(EmptyPromise(
            _check_course_available,
            "Found course {course_id} in the list of available courses".format(course_id=course_id),
            try_limit=3, try_interval=2
        ))
Beispiel #32
0
    def test_language_persists(self):
        auto_auth_page = AutoAuthPage(self.browser, username=self.username, password=self.password, email=self.email, course_id=self.course_id)
        auto_auth_page.visit()

        self.dashboard_page.visit()
        # Change language to Dummy Esperanto
        self.dashboard_page.change_language(self.test_new_lang)

        # destroy session
        self.browser._cookie_manager.delete()

        # log back in
        auto_auth_page.visit()

        self.dashboard_page.visit()

        changed_text = fulfill(self._changed_lang_promise)
        # We should see the dummy-language text on the page
        self.assertIn(self.current_courses_text, changed_text)
Beispiel #33
0
    def test_language_persists(self):
        auto_auth_page = AutoAuthPage(self.browser, username=self.username, password=self.password, email=self.email, course_id=self.course_id)
        auto_auth_page.visit()

        self.dashboard_page.visit()
        # Change language to Dummy Esperanto
        self.dashboard_page.change_language(self.test_new_lang)

        # destroy session
        self.browser._cookie_manager.delete()

        # log back in
        auto_auth_page.visit()

        self.dashboard_page.visit()

        changed_text = fulfill(self._changed_lang_promise)
        # We should see the dummy-language text on the page
        self.assertIn(self.current_courses_text, changed_text)
Beispiel #34
0
 def delete_comment(self, comment_id):
     with self.handle_alert():
         self.css_click("#comment_{} div.action-delete".format(comment_id))
     fulfill(
         EmptyPromise(lambda: not self.is_comment_visible(comment_id),
                      "Deleted comment was removed"))