course_info.py 4.76 KB
Newer Older
1 2 3
"""
Course Updates page.
"""
4
from common.test.acceptance.pages.common.utils import click_css, confirm_prompt
5
from common.test.acceptance.pages.studio.course_page import CoursePage
6
from common.test.acceptance.pages.studio.utils import type_in_codemirror, set_input_value
7 8


9
class CourseUpdatesPage(CoursePage):
10 11 12
    """
    Course Updates page.
    """
13
    url_path = "course_info"
14 15

    def is_browser_on_page(self):
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
        """
        Returns whether or not the browser on the page and has loaded the required content
        """
        # Check for the presence of handouts-content, when it is present the render function has completed
        # loading the updates and handout sections
        return (self.q(css='.handouts-content').present and
                self.q(css='article#course-update-view.course-updates').present)

    def is_course_update_list_empty(self):
        """
        Checks whether or not the update contents list is empty
        """
        return len(self.q(css='.update-contents')) == 0

    def is_new_update_button_present(self):
        """
        Checks for the presence of the new update post button.
        """
        return self.q(css='.new-update-button').present

    def click_new_update_button(self):
        """
        Clicks the new-update button.
        """
40 41 42 43 44 45 46 47
        def is_update_button_enabled():
            """
            Checks if the New Update button is enabled
            """
            return self.q(css='.new-update-button').attrs('disabled')[0] is None

        self.wait_for(promise_check_func=is_update_button_enabled,
                      description='Waiting for the New update button to be enabled.')
48
        click_css(self, '.new-update-button', require_notification=False)
49
        self.wait_for_element_visibility('.CodeMirror', 'Waiting for .CodeMirror')
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

    def submit_update(self, message):
        """
        Adds update text to the new update CodeMirror form and submits that text.

        Arguments:
            message (str): The message to be added and saved.
        """
        type_in_codemirror(self, 0, message)
        self.click_new_update_save_button()

    def set_date(self, date):
        """
        Sets the updates date input to the provided value.

        Arguments:
            date (str): Date string in the format DD/MM/YYYY
        """
        set_input_value(self, 'input.date', date)

    def is_first_update_date(self, search_date):
        """
        Checks to see if the search date is present

        Arguments:
            search_date (str): e.g. 06/01/2013 would be found with June 1, 2013

        Returns:
             bool: True if the date is in the first update and False otherwise.
        """
        return search_date == self.q(css='.date-display').html[0]

    def is_new_update_save_button_present(self):
        """
        Checks to see if the CodeMirror Update save button is present.
        """
        return self.q(css='.save-button').present

    def click_new_update_save_button(self):
        """
        Clicks the CodeMirror Update save button.
        """
        click_css(self, '.save-button')

    def is_edit_button_present(self):
        """
        Checks to see if the edit update post buttons if present.
        """
        return self.q(css='.post-preview .edit-button').present

    def click_edit_update_button(self):
        """
        Clicks the edit update post button.
        """
        click_css(self, '.post-preview .edit-button', require_notification=False)
        self.wait_for_element_visibility('.CodeMirror', 'Waiting for .CodeMirror')

    def is_delete_update_button_present(self):
        """
        Checks to see if the delete update post button is present.
        """
        return self.q(css='.post-preview .delete-button').present

    def click_delete_update_button(self):
        """
        Clicks the delete update post button and confirms the delete notification.
        """
        click_css(self, '.post-preview .delete-button', require_notification=False)
        confirm_prompt(self)

    def is_first_update_message(self, message):
        """
        Looks for the message in the first course update posted.

        Arguments:
            message (str): String containing the message that is to be searched for

        Returns:
            bool: True if the first update is the message, false otherwise.
        """
        return message == self.q(css='.update-contents').html[0]

    def first_update_contains_html(self, value):
        """
        Looks to see if the html provided is contained in the first update

        Arguments:
            value (str): String value that will be looked for

        Returns:
            bool: True if the value is contained in the first update
        """
        update = self.q(css='.update-contents').html
        return value in update[0]