Example #1
0
def test_non_logged_in_users_on_mobile_are_directed_to_log_in_for_errata_form(
        web_base_url, selenium, teacher):
    """Test non-logged in users on mobile trying to view the form."""
    # GIVEN: a user viewing a current edition book details page
    # AND:  have a valid login and password
    # AND:  are not logged into the website
    # AND:  the screen width is 600 pixels
    home = WebHome(selenium, web_base_url)
    home.resize_window(width=Web.PHONE)
    home.open()
    home.web_nav.meta.toggle_menu()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.AVAILABLE,
                                       filter_current=True)
    book_title = book.title
    book_errata = book.phone.errata.errata_append

    # WHEN: they click on the "Report errata" bar
    # AND:  click on the "Suggest a correction" button
    book.phone.errata.toggle()
    accounts = book.phone.errata.submit_errata()

    # THEN: the Accounts login page is displayed
    assert(accounts.is_displayed()), 'Accounts login page not displayed'
    assert('accounts' in accounts.location), \
        f'Not on an Accounts instance ({accounts.location})'

    # WHEN: they log into Accounts
    errata_form = accounts.service_log_in(
        *teacher, ErrataForm, web_base_url, book=book_errata)

    # THEN: the errata form is displayed
    # AND:  the subject is prefilled in
    assert(errata_form.is_displayed())
    assert(book_title in errata_form.subject)
Example #2
0
def test_non_logged_in_users_are_directed_to_log_in_to_view_the_errata_form(
        web_base_url, selenium, teacher):
    """Test non-logged in users trying to view the form are asked to log in."""
    # GIVEN: a user viewing a current edition book details page
    # AND:   have a valid login and password
    # AND:   are not logged into the website
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.AVAILABLE,
                                       filter_current=True)
    book_title = book.title
    book_errata = book.details.errata_append

    # WHEN: they click on the "Suggest a correction" button
    accounts = book.details.submit_errata()

    # THEN: the Accounts login page is displayed
    assert(accounts.is_displayed()), 'Accounts login page not displayed'
    assert('accounts' in accounts.location), \
        f'Not on an Accounts instance ({accounts.location})'

    # WHEN: they log into Accounts
    errata_form = accounts.service_log_in(
        *teacher, ErrataForm, web_base_url, book=book_errata)

    # THEN: the errata form is displayed
    # AND:  the subject is prefilled in
    assert(errata_form.is_displayed()), 'Errata form not displayed'
    assert(book_title in errata_form.subject), (
        f'Errata form book ({errata_form.subject}) '
        f'does not match used book ({book_title})')
Example #3
0
def test_logged_out_users_are_sent_to_accounts_to_log_in_to_view_dashboard(
        accounts_base_url, web_base_url, selenium):
    """Logged out users are sent to Accounts to log in for their dashboard."""
    # GIVEN: a user viewing the Tutor marketing page
    # AND:  not logged into the site
    home = WebHome(selenium, web_base_url).open()
    tutor_marketing = home.web_nav.technology.view_tutor()

    # WHEN: they click on the "Access Your Course" button
    accounts = (
        tutor_marketing.introduction.access_your_course(accounts_base_url))

    # THEN: the Accounts log in page is displayed in a new tab
    assert (accounts.is_displayed())
    assert ('login' in accounts.location)
Example #4
0
def test_teachers_are_asked_to_sign_up_to_access_locked_content(
        web_base_url, selenium):
    """Test users are directed to sign up to access locked resources."""
    # GIVEN: a user viewing the book details page
    # AND:  are not logged into the website
    # AND:  the book has instructor resources
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.HAS_I_LOCK)

    # WHEN: they click on the "Sign up" link
    book.select_tab(Web.INSTRUCTOR_RESOURCES)
    accounts = book.instructor.sign_up()

    # THEN: the Accounts sign up page is displayed
    assert(accounts.is_displayed()), 'Accounts login page not displayed'
    assert('accounts' in accounts.location), \
        f'Not on an Accounts instance ({accounts.location})'
Example #5
0
def test_students_sign_up_to_access_locked_student_content(
        accounts_base_url, web_base_url, selenium):
    """Users are directed to sign up to access locked student content."""
    # SETUP:
    name = Utility.random_name()
    email = RestMail(f'{name[1]}.{name[2]}.{Utility.random_hex(4)}'.lower())
    email.empty()
    password = Utility.random_hex(20)

    # GIVEN: a user viewing the student resources on a book details page
    # AND:  is not logged into the site
    # AND:  there is a locked student resource
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.HAS_S_LOCK)
    book.select_tab(Web.STUDENT_RESOURCES)

    # WHEN: they click on "Click here to unlock" link
    options = book.student.resources_by_option(Web.LOCKED)
    assert(options), f'No locked student resources found for {book.title}'
    option = options[Utility.random(0, len(options) - 1)]
    option_title = option.title
    option.select()
    accounts = AccountsHome(selenium, accounts_base_url)

    # THEN: the Accounts sign up page is displayed
    assert(accounts.is_displayed()), 'Accounts login page not displayed'
    assert('accounts' in accounts.location), \
        f'Not on an Accounts instance ({accounts.location})'

    # WHEN: they sign up
    book = accounts.student_signup(name[1], name[2], password, email,
                                   Book, web_base_url)

    # THEN: the student resources on the book details page is displayed
    # AND:  the resource is available for download
    assert(book.student.is_displayed()), \
        f'Student resources not displayed ({book.location})'
    option = book.student.resource_by_name(option_title)
    assert(not option.is_locked), f'{option.title} is still locked'
Example #6
0
def test_verified_instructors_may_access_locked_resources(
        accounts_base_url, web_base_url, selenium, teacher):
    """Test verified instructors may access locked resources."""
    # GIVEN: a user viewing the book details page
    # AND:  they have a valid instructor login and password
    # AND:  they are not logged into the website
    # AND:  the book has locked instructor resources
    home = WebHome(selenium, web_base_url).open()
    subjects = home.web_nav.subjects.view_all()
    book = subjects.select_random_book(_from=Library.HAS_I_LOCK)

    # WHEN: they click on the "Instructor resources" tab
    # AND:  click on the "Click here to unlock" link
    book.select_tab(Web.INSTRUCTOR_RESOURCES)
    options = book.instructor.resources_by_option(Web.LOCKED)
    assert(options), 'No locked instructor resources found'
    option = options[Utility.random(0, len(options) - 1)]
    option_title = option.title
    option.select()
    accounts = AccountsHome(selenium, accounts_base_url)

    # THEN: the Accounts login page is displayed
    assert(accounts.is_displayed()), 'Accounts login page not displayed'
    assert('accounts' in accounts.location), \
        f'Not on an Accounts instance ({accounts.location})'

    # WHEN: they log into Accounts
    accounts.service_log_in(*teacher, Book, web_base_url)

    # THEN: the instructor resources tab on the book details page is displayed
    # AND:  the resource is no longer locked
    assert(book.instructor.is_displayed()), \
        f'Instructor resources not displayed ({book.location})'
    option = book.instructor.resource_by_name(option_title)
    assert(not option.is_locked), \
        '{option} is still locked'.format(option=option.title)