Esempio n. 1
0
 def _selection_helper(self, modifier):
     """Return a list of books for a modified collection."""
     library = Library()
     collection = library.get_titles(modifier)
     return [
         book for book in self._active_books if book.title in collection
     ]
Esempio n. 2
0
def test_page_links_to_the_interest_form(web_base_url, selenium):
    """Test the interest form link."""
    # GIVEN: a user viewing the book details page
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.AVAILABLE)

    # WHEN: they click on the "Sign up to learn more" link
    library = Library()
    passed_title = library.get(book.title, Library.INTEREST)
    interest = book.is_interested()

    # THEN: the interest form is displayed
    # AND:  the book title is passed in the URL
    assert(interest.is_displayed())
    assert('interest' in interest.location)
    assert(passed_title in interest.location)
Esempio n. 3
0
def test_page_links_to_the_adoption_form(web_base_url, selenium):
    """Test the adoption form link."""
    # GIVEN: a user viewing the book details page
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.AVAILABLE)

    # WHEN: they click on the "Using this book? Let us know." link
    library = Library()
    passed_title = library.get(book.title, Library.ADOPTION)
    adoption = book.is_using()

    # THEN: the adoption form is displayed
    # AND:  the book title is passed in the URL
    assert(adoption.is_displayed())
    assert('adoption' in adoption.location)
    assert(passed_title in adoption.location)
def test_non_student_users_submit_the_adoption_form(web_base_url, selenium):
    """Test that a non-student user is able to submit the adoption form.

    Salesforce verification of the form is not tested.
    """
    # SETUP:
    user_type = Web.USERS[Utility.random(1, len(Web.USERS) - 1)]
    _, first_name, last_name, _ = Utility.random_name()
    email = RestMail('{first}.{last}.{rand}'.format(
        first=first_name, last=last_name, rand=Utility.random_hex(3)).lower())
    phone = Utility.random_phone(713, False)
    school = 'Automation'
    book_list = Library().random_book()
    books = {}
    for book in book_list:
        books[book] = {
            'status':
            Web.USING_STATUS[Utility.random(0,
                                            len(Web.USING_STATUS) - 1)],
            'students':
            Utility.random(Web.STUDENT_MIN, Web.STUDENT_MAX)
        }
    tech_providers = TechProviders.get_tech(Utility.random(0, 3))
    if TechProviders.OTHER in tech_providers:
        other = 'Another product provider'
    else:
        other = None

    # GIVEN: a user viewing the adoption page
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    initial_book = choice(list(books.keys()))
    book = subjects.select_book(initial_book)
    adoption = book.is_using()

    # WHEN: they select a non-Student role from the drop down menu
    # AND:  fill out the contact form fields
    # AND:  click on the "Next" button
    # AND:  select a book subject
    # AND:  select a radio option from "How are you using <book>?"
    # AND:  enter a number of students
    # AND:  click on the "Next" button
    # AND:  select a technology provider
    # AND:  click on the "Submit" button
    book = adoption.submit_adoption(user_type=user_type,
                                    first=first_name,
                                    last=last_name,
                                    email=email.address,
                                    phone=phone,
                                    school=school,
                                    books=books,
                                    tech_providers=tech_providers,
                                    other_provider=other)

    # THEN: the book's instructor resources page is displayed
    assert (book.is_displayed())
    assert ('books' in book.location)
def test_a_book_is_preselected_when_a_book_details_adoption_link_is_used(
        web_base_url, selenium):
    """Test using a book details page adoption link prefills the book."""
    # SETUP:
    user_type = Web.USERS[Utility.random(1, len(Web.USERS) - 1)]
    _, first_name, last_name, _ = Utility.random_name()
    email = RestMail('{first}.{last}.{rand}'.format(
        first=first_name, last=last_name, rand=Utility.random_hex(4)).lower())
    phone = Utility.random_phone(713, False)
    school = 'Automation'
    book, short, full, detail_append = Library().get_name_set()
    books = {
        short: {
            'status': '',
            'students': '',
        }
    }

    # GIVEN: a user viewing a book page
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.AVAILABLE)
    adoption = book.is_using()

    # WHEN: they click on the "Using this book? Let us know." link
    # AND:  select a non-Student role from the drop down menu
    # AND:  fill out the contact form fields
    # AND:  click on the "Next" button
    with pytest.raises(WebException) as error:
        adoption.submit_adoption(user_type=user_type,
                                 first=first_name,
                                 last=last_name,
                                 email=email.address,
                                 phone=phone,
                                 school=school,
                                 books=books)

    # THEN: the book is selected
    # AND:  the using questions for the book are displayed
    assert(short in Utility.get_error_information(error)), \
        '{book} ({short}) not preselected'.format(book=full, short=short)
def test_non_students_may_fill_out_the_form(web_base_url, selenium):
    """Test non-students may fill out and submit the interest form.

    Salesforce verification of the form is not tested.
    """
    # SETUP:
    user_type = Web.USERS[Utility.random(1, len(Web.USERS) - 1)]
    _, first_name, last_name, _ = Utility.random_name()
    email = RestMail(
        f'{first_name}.{last_name}.{Utility.random_hex(3)}'.lower())
    phone = Utility.random_phone(713, False)
    school = 'Automation'
    books = Library().random_book(Utility.random(start=2, end=5))
    students = Utility.random(Web.STUDENT_MIN, Web.STUDENT_MAX)
    tech_providers = TechProviders.get_tech(Utility.random(0, 3))
    other = 'Another product provider' \
        if TechProviders.OTHER in tech_providers else None

    # GIVEN: a user viewing the interest page
    interest = Interest(selenium, web_base_url).open()
    if interest.survey.is_displayed():
        interest.survey.close()
    if interest.privacy_notice.is_displayed():
        interest.privacy_notice.got_it()

    # WHEN: they select a non-Student role from the drop down menu
    # AND:  fill out the contact form fields
    # AND:  click on the "Next" button
    # AND:  select a book subject
    # AND:  enter a number of students
    # AND:  select zero to three partner options
    # AND:  select zero to eight "How did you hear?" options
    # AND:  click on the "Next" button
    # AND:  select zero or more technology options
    # AND:  click on the "Submit" button
    partners = interest.submit_interest(user_type=user_type,
                                        first=first_name,
                                        last=last_name,
                                        email=email.address,
                                        phone=phone,
                                        school=school,
                                        books=books,
                                        students=students,
                                        additional_resources=Web.resources(),
                                        heard_on=Web.heard_by(),
                                        tech_providers=tech_providers,
                                        other_provider=other)

    # THEN: the partners page is displayed
    assert(partners.is_displayed()), \
        'Partners page not displayed'
    assert('partners' in partners.location), \
        f'Not at the interest confirmation page ({partners.location})'
Esempio n. 7
0
    def select_book(self, book_title):
        """Return the book page for a specific title.

        :param str book_title: the full book title found in the alt field
        :return: the book page for the selected title
        :rtype: :py:class:`~pages.web.book.Book`

        """
        field = Library.SHORT_NAME if 'calculus' in book_title \
            else Library.DETAILS
        append = Library().get(book_title, field=field)
        selector = '[href$="{book_details}"]'.format(book_details=append)
        book = self.find_element(By.CSS_SELECTOR, selector)
        Utility.click_option(self.driver, element=book)
        from pages.web.book import Book as Details
        return go_to_(Details(self.driver, book_name=append))
def test_a_book_is_preselected_when_a_book_details_interest_link_is_used(
        web_base_url, selenium):
    """Test the book is already selected when passed in the URL."""
    # SETUP:
    user_type = Web.USERS[Utility.random(1, len(Web.USERS) - 1)]
    _, first_name, last_name, _ = Utility.random_name()
    email = RestMail('{first}.{last}.{rand}'.format(
        first=first_name, last=last_name, rand=Utility.random_hex(4)).lower())
    phone = Utility.random_phone(713, False)
    school = 'Automation'
    book, short, full, detail_append = Library().get_name_set()
    books = [short]
    students = ''

    # GIVEN: a user viewing a book page
    book_details = Book(selenium, web_base_url, book_name=detail_append).open()

    # WHEN: they click on the "Sign up to learn more" link
    # AND:  select a non-Student role from the drop down menu
    # AND:  fill out the contact form fields
    # AND:  click on the "Next" button
    interest = book_details.is_interested()
    if interest.survey.is_displayed():
        interest.survey.close()
    if interest.privacy_notice.is_displayed():
        interest.privacy_notice.got_it()
    with pytest.raises(WebException) as error:
        interest.submit_interest(user_type=user_type,
                                 first=first_name,
                                 last=last_name,
                                 email=email.address,
                                 phone=phone,
                                 school=school,
                                 books=books,
                                 students=students,
                                 additional_resources=Web.resources(),
                                 heard_on=Web.heard_by())

    # THEN: the book is selected
    selection = interest.form.selection
    assert(short in selection), \
        f'{short} not in the current selection ({selection})'
    assert('Using error' in Utility.get_error_information(error)), \
        'No book is preselected'
Esempio n. 9
0
 def select_book(self, book):
     """Select a book from the proxy menu."""
     menu = self.find_element(*self._proxy_select_locator)
     options = self.find_element(*self._option_list_locator)
     details = Library().get(book, Library.DETAILS)
     option = self.find_element(By.CSS_SELECTOR,
                                f'[data-value={details}]')
     offset = self.driver.execute_script(
         'return arguments[0].offsetTop;', option)
     if 'open' not in menu.get_attribute('class'):
         Utility.click_option(self.driver, element=menu)
     self.driver.execute_script(
         'arguments[0].scrollTop = {offset};'.format(offset=offset),
         options)
     sleep(0.2)
     Utility.click_option(self.driver,
                          element=option,
                          force_js_click=True)
     return self.page
Esempio n. 10
0
 def bookshare_books(self):
     """Select active books available through Bookshare."""
     return self._selection_helper(Library().bookshare)
Esempio n. 11
0
 def available_books(self):
     """Select active books."""
     return self._selection_helper(Library().available)
Esempio n. 12
0
 def comp_copy(self):
     """Select the current editions of each book."""
     return self._selection_helper(Library().comp_copy)
Esempio n. 13
0
 def business_books(self):
     """Select active business books."""
     return self._selection_helper(Library().business)
Esempio n. 14
0
 def unlocked_instructor(self):
     """Select active books with unlocked instructor resources."""
     return self._selection_helper(Library().unlocked_instructor)
Esempio n. 15
0
 def unlocked_student(self):
     """Select active books with unlocked student resources."""
     return self._selection_helper(Library().unlocked_student)
Esempio n. 16
0
 def science_books(self):
     """Select active science books."""
     return self._selection_helper(Library().science)
Esempio n. 17
0
 def humanities_books(self):
     """Select active humanities books."""
     return self._selection_helper(Library().humanities)
Esempio n. 18
0
 def old_book_editions(self):
     """Select the books with a newer editions available."""
     return self._selection_helper(Library().superseded)
Esempio n. 19
0
 def print_books(self):
     """Select the books with a current print edition available."""
     return self._selection_helper(Library().print)
Esempio n. 20
0
 def current_books(self):
     """Select the current editions of each book."""
     return self._selection_helper(Library().current)
Esempio n. 21
0
 def itunes_books(self):
     """Select active books with an iBook eddition available."""
     return self._selection_helper(Library().itunes)
Esempio n. 22
0
 def kindle_books(self):
     """Select active books with a Kindle edition available."""
     return self._selection_helper(Library().kindle)
Esempio n. 23
0
 def ap_books(self):
     """Select active AP books."""
     return self._selection_helper(Library().ap)
Esempio n. 24
0
 def social_sciences_books(self):
     """Select active social science books."""
     return self._selection_helper(Library().social_sciences)
Esempio n. 25
0
 def math_books(self):
     """Select active math books."""
     return self._selection_helper(Library().math)
Esempio n. 26
0
 def essentials_books(self):
     """Select active essentials books."""
     return self._selection_helper(Library().essentials)