Esempio n. 1
0
 def wait_for_filename_error(self):
     """
     Wait for the upload field to display an error.
     """
     EmptyPromise(self.is_filename_error_showing, 'Upload Error Displayed', timeout=30).fulfill()
Esempio n. 2
0
    def _verify_csv_upload_acceptable_file(self, filename):
        """
        Helper method to verify cohort assignments after a successful CSV upload.
        """
        start_time = datetime.now(UTC)
        self.cohort_management_page.upload_cohort_file(filename)
        self._verify_cohort_by_csv_notification(
            "Your file '{}' has been uploaded. Allow a few minutes for processing."
            .format(filename))

        # student_user is moved from manual cohort to auto cohort
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_added",
                "time": {
                    "$gt": start_time
                },
                "event.user_id": {
                    "$in": [int(self.student_id)]
                },
                "event.cohort_name":
                self.auto_cohort_name,
            }).count(), 1)
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_removed",
                "time": {
                    "$gt": start_time
                },
                "event.user_id":
                int(self.student_id),
                "event.cohort_name":
                self.manual_cohort_name,
            }).count(), 1)
        # instructor_user (previously unassigned) is added to manual cohort
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_added",
                "time": {
                    "$gt": start_time
                },
                "event.user_id": {
                    "$in": [int(self.instructor_id)]
                },
                "event.cohort_name":
                self.manual_cohort_name,
            }).count(), 1)
        # unicode_student_user (previously unassigned) is added to manual cohort
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_added",
                "time": {
                    "$gt": start_time
                },
                "event.user_id": {
                    "$in": [int(self.unicode_student_id)]
                },
                "event.cohort_name":
                self.manual_cohort_name,
            }).count(), 1)

        # Verify the results can be downloaded.
        data_download = self.instructor_dashboard_page.select_data_download()
        EmptyPromise(
            lambda: 1 == len(data_download.get_available_reports_for_download(
            )), 'Waiting for downloadable report').fulfill()
        report = data_download.get_available_reports_for_download()[0]
        base_file_name = "cohort_results_"
        self.assertIn(
            "{}_{}".format(
                '_'.join([
                    self.course_info['org'], self.course_info['number'],
                    self.course_info['run']
                ]), base_file_name), report)
        report_datetime = datetime.strptime(
            report[report.index(base_file_name) +
                   len(base_file_name):-len(".csv")], "%Y-%m-%d-%H%M")
        self.assertLessEqual(start_time.replace(second=0, microsecond=0),
                             utc.localize(report_datetime))
 def wait_for_signatory_delete_prompt(self):
     """
     Promise to wait until signatory delete prompt is visible
     """
     EmptyPromise(lambda: self.q(css='a.button.action-primary').present,
                  'Delete prompt is displayed').fulfill()
Esempio n. 4
0
 def perform_search(self, text="dummy"):
     self.q(css=".forum-nav-search-input").fill(text + chr(10))
     EmptyPromise(self.is_ajax_finished,
                  "waiting for server to return result").fulfill()
Esempio n. 5
0
 def wait_for_upload(self):
     """
     Wait for the upload to be confirmed.
     """
     EmptyPromise(self.is_upload_finished, 'Upload Finished',
                  timeout=30).fulfill()
Esempio n. 6
0
 def click_new_post_button(self):
     self.click_element(".new-post-btn")
     EmptyPromise(self.is_new_post_opened, "New post opened").fulfill()
Esempio n. 7
0
 def click_next_page(self):
     self._click_pager_with_text(self.TEXT_NEXT,
                                 self.get_current_page() + 1)
     EmptyPromise(self.is_window_on_top, "Window is on top").fulfill()
Esempio n. 8
0
 def scored(self, scored):
     """
     Sets value of scored select
     """
     self.set_select_value(self.SCORED_LABEL, str(scored))
     EmptyPromise(lambda: self.scored == scored, "scored is updated in modal.").fulfill()
Esempio n. 9
0
 def capa_type(self, value):
     """
     Sets value of CAPA type select
     """
     self.set_select_value(self.PROBLEM_TYPE_LABEL, value)
     EmptyPromise(lambda: self.capa_type == value, "problem type is updated in modal.").fulfill()
Esempio n. 10
0
 def wait_for_export(self):
     """
     Wait for the export process to finish.
     """
     EmptyPromise(self.is_export_finished, 'Export Finished',
                  timeout=30).fulfill()
Esempio n. 11
0
 def library_name(self, library_name):
     """
     Select a library from the library select box
     """
     self.set_select_value(self.LIBRARY_LABEL, library_name)
     EmptyPromise(lambda: self.library_name == library_name, "library_name is updated in modal.").fulfill()
Esempio n. 12
0
 def _changed_lang_promise(self, code):
     def _check_func():
         return self.q(css='select[name="language"] option[value="{}"]'.format(code)).selected
     return EmptyPromise(_check_func, "language changed")
Esempio n. 13
0
 def check_focus_is_set(self, selector):
     """
     Check focus is set
     """
     EmptyPromise(lambda: self.is_focused_on_element(selector),
                  "Focus is on other element").fulfill()
Esempio n. 14
0
 def wait_for_timestamp_visible(self):
     """
     Wait for the timestamp of the last successful import/export to be visible.
     """
     EmptyPromise(self.is_timestamp_visible, 'Timestamp Visible', timeout=30).fulfill()
Esempio n. 15
0
 def expand_discussion(self):
     """Click the link to expand the discussion"""
     self._find_within(".discussion-show").first.click()
     EmptyPromise(self.is_discussion_expanded,
                  "Discussion expanded").fulfill()
Esempio n. 16
0
 def wait_for_loading_indicator(self):
     """
     Wait for loading indicator to become visible.
     """
     EmptyPromise(self._is_loading_in_progress,
                  "Loading is in progress.").fulfill()
Esempio n. 17
0
 def click_cancel_new_post(self):
     self.click_element(".cancel")
     EmptyPromise(lambda: not self.is_new_post_opened(),
                  "New post closed").fulfill()
Esempio n. 18
0
 def click_bookmark_unit_button(self):
     """ Bookmark a unit by clicking on Bookmark button """
     previous_state = self.bookmark_button_state
     self.q(css='.bookmark-button').first.click()
     EmptyPromise(lambda: self.bookmark_button_state != previous_state,
                  "Bookmark button toggled").fulfill()
Esempio n. 19
0
 def expand(self):
     """Clicks the link to expand the thread"""
     self._find_within(".forum-thread-expand").first.click()
     EmptyPromise(lambda: bool(self.get_response_total_text()),
                  "Thread expanded").fulfill()
Esempio n. 20
0
    def login(self, email, password):
        submit_lms_login_form(self, email, password)

        # Wait for LMS to redirect to the dashboard
        EmptyPromise(self._is_browser_on_lms_dashboard,
                     "LMS login redirected to dashboard").fulfill()
Esempio n. 21
0
 def click_on_page(self, page_number):
     self._click_pager_with_text(unicode(page_number), page_number)
     EmptyPromise(self.is_window_on_top, "Window is on top").fulfill()
Esempio n. 22
0
 def edit(self):
     self.q(css=self._bounded_selector(
         self.CONFIGURATION_BUTTON_SELECTOR)).first.click()
     modal = CourseOutlineModal(self)
     EmptyPromise(lambda: modal.is_shown(), 'Modal is shown.')
     return modal
Esempio n. 23
0
    def load_more_responses(self):
        """Clicks the load more responses button and waits for responses to load"""
        self._find_within(".load-response-button").click()

        EmptyPromise(self.is_ajax_finished, "Loading more Responses").fulfill()
Esempio n. 24
0
 def delete_comment(self, comment_id):
     with self.handle_alert():
         self.q(css="#comment_{} div.action-delete".format(
             comment_id)).first.click()
     EmptyPromise(lambda: not self.is_comment_visible(comment_id),
                  "Deleted comment was removed").fulfill()
Esempio n. 25
0
    def test_add_students_to_cohort_success(self):
        """
        Scenario: When students are added to a cohort, the appropriate notification is shown.

        Given I have a course with two cohorts
        And there is a user in one cohort
        And there is a user in neither cohort
        When I add the two users to the cohort that initially had no users
        Then there are 2 users in total in the cohort
        And I get a notification that 2 users have been added to the cohort
        And I get a notification that 1 user was moved from the other cohort
        And the user input field is empty
        And appropriate events have been emitted
        """
        start_time = datetime.now(UTC)
        self.cohort_management_page.select_cohort(self.auto_cohort_name)
        self.assertEqual(
            0, self.cohort_management_page.get_selected_cohort_count())
        self.cohort_management_page.add_students_to_selected_cohort(
            [self.student_name, self.instructor_name])
        # Wait for the number of users in the cohort to change, indicating that the add operation is complete.
        EmptyPromise(
            lambda: 2 == self.cohort_management_page.get_selected_cohort_count(
            ), 'Waiting for added students').fulfill()
        confirmation_messages = self.cohort_management_page.get_cohort_confirmation_messages(
        )
        self.assertEqual([
            "2 students have been added to this cohort",
            "1 student was removed from " + self.manual_cohort_name
        ], confirmation_messages)
        self.assertEqual(
            "",
            self.cohort_management_page.get_cohort_student_input_field_value())
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_added",
                "time": {
                    "$gt": start_time
                },
                "event.user_id": {
                    "$in": [int(self.instructor_id),
                            int(self.student_id)]
                },
                "event.cohort_name":
                self.auto_cohort_name,
            }).count(), 2)
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_removed",
                "time": {
                    "$gt": start_time
                },
                "event.user_id":
                int(self.student_id),
                "event.cohort_name":
                self.manual_cohort_name,
            }).count(), 1)
        self.assertEqual(
            self.event_collection.find({
                "name": "edx.cohort.user_add_requested",
                "time": {
                    "$gt": start_time
                },
                "event.user_id": int(self.instructor_id),
                "event.cohort_name": self.auto_cohort_name,
                "event.previous_cohort_name": None,
            }).count(), 1)
        self.assertEqual(
            self.event_collection.find({
                "name":
                "edx.cohort.user_add_requested",
                "time": {
                    "$gt": start_time
                },
                "event.user_id":
                int(self.student_id),
                "event.cohort_name":
                self.auto_cohort_name,
                "event.previous_cohort_name":
                self.manual_cohort_name,
            }).count(), 1)
Esempio n. 26
0
 def start_response_edit(self, response_id):
     """Click the edit button for the response, loading the editing view"""
     self.q(css=".response_{} .discussion-response .action-edit".format(
         response_id)).first.click()
     EmptyPromise(lambda: self.is_response_editor_visible(response_id),
                  "Response edit started").fulfill()
 def wait_for_signatory_delete_icon(self):
     """
     Returns whether or not the delete icon is present.
     """
     EmptyPromise(lambda: self.q(css='.signatory-panel-delete').present,
                  'Delete icon is displayed').fulfill()
Esempio n. 28
0
    def _verify_cohort_settings(self,
                                cohort_name,
                                assignment_type=None,
                                new_cohort_name=None,
                                new_assignment_type=None,
                                verify_updated=False):
        """
        Create a new cohort and verify the new and existing settings.
        """
        start_time = datetime.now(UTC)
        self.assertNotIn(cohort_name,
                         self.cohort_management_page.get_cohorts())
        self.cohort_management_page.add_cohort(cohort_name,
                                               assignment_type=assignment_type)
        self.assertEqual(
            0, self.cohort_management_page.get_selected_cohort_count())
        # After adding the cohort, it should automatically be selected and its
        # assignment_type should be "manual" as this is the default assignment type
        _assignment_type = assignment_type or 'manual'
        msg = "Waiting for currently selected cohort assignment type"
        EmptyPromise(
            lambda: _assignment_type == self.cohort_management_page.
            get_cohort_associated_assignment_type(), msg).fulfill()
        # Go back to Manage Students Tab
        self.cohort_management_page.select_manage_settings()
        self.cohort_management_page.add_students_to_selected_cohort(
            [self.instructor_name])
        # Wait for the number of users in the cohort to change, indicating that the add operation is complete.
        EmptyPromise(
            lambda: 1 == self.cohort_management_page.get_selected_cohort_count(
            ), 'Waiting for student to be added').fulfill()
        self.assertFalse(
            self.cohort_management_page.is_assignment_settings_disabled)
        self.assertEqual(
            '', self.cohort_management_page.assignment_settings_message)
        self.assertEqual(
            self.event_collection.find({
                "name": "edx.cohort.created",
                "time": {
                    "$gt": start_time
                },
                "event.cohort_name": cohort_name,
            }).count(), 1)
        self.assertEqual(
            self.event_collection.find({
                "name": "edx.cohort.creation_requested",
                "time": {
                    "$gt": start_time
                },
                "event.cohort_name": cohort_name,
            }).count(), 1)

        if verify_updated:
            self.cohort_management_page.select_cohort(cohort_name)
            self.cohort_management_page.select_cohort_settings()
            self.cohort_management_page.set_cohort_name(new_cohort_name)
            self.cohort_management_page.set_assignment_type(
                new_assignment_type)
            self.cohort_management_page.save_cohort_settings()

            # If cohort name is empty, then we should get/see an error message.
            if not new_cohort_name:
                confirmation_messages = self.cohort_management_page.get_cohort_settings_messages(
                    type='error')
                self.assertEqual([
                    "The cohort cannot be saved",
                    "You must specify a name for the cohort"
                ], confirmation_messages)
            else:
                confirmation_messages = self.cohort_management_page.get_cohort_settings_messages(
                )
                self.assertEqual(["Saved cohort"], confirmation_messages)
                self.assertEqual(
                    new_cohort_name,
                    self.cohort_management_page.cohort_name_in_header)
                self.assertIn(new_cohort_name,
                              self.cohort_management_page.get_cohorts())
                self.assertEqual(
                    1, self.cohort_management_page.get_selected_cohort_count())
                self.assertEqual(
                    new_assignment_type,
                    self.cohort_management_page.
                    get_cohort_associated_assignment_type())
Esempio n. 29
0
 def bookmark_button_visible(self):
     """ Check if bookmark button is visible """
     EmptyPromise(lambda: self.q(css='.bookmark-button').visible, "Bookmark button visible").fulfill()
     return True
Esempio n. 30
0
 def wait_for_export_click_handler(self):
     """
     Wait for the export button click handler to be registered
     """
     EmptyPromise(self.is_click_handler_registered, 'Export Button Click Handler Registered', timeout=30).fulfill()