def test_login_failure(self):
     selenium.get(self.live_server_url)
     page = HomePage(selenium)
     page = page.go_to_teach_page()
     page = page.login_failure('*****@*****.**', 'Incorrect password')
     assert page.has_login_failed()
     assert self.is_teach_page(page)
    def test_edit_details(self):
        email, password = signup_teacher_directly()
        name, postcode = create_organisation_directly(email)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser)\
            .go_to_teach_page()\
            .login(email, password)\
            .go_to_organisation_manage_page()

        assert page.check_organisation_details({
            'name': name,
            'postcode': postcode
        })

        new_name = 'new ' + name
        new_postcode = 'OX2 6LE'

        page.change_organisation_details({
            'name': new_name,
            'postcode': new_postcode
        })
        assert page.check_organisation_details({
            'name': new_name,
            'postcode': new_postcode
        })
    def test_change_password(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_play_page()\
            .school_login(student_name, access_code, student_password)\
            .go_to_account_page()

        new_password = '******' + student_password
        page = page.change_account_details({
            'password': new_password,
            'confirm_password': new_password,
            'current_password': student_password
        })

        page = page.logout()\
            .go_to_play_page()\
            .school_login_incorrect(student_name, access_code, student_password)

        assert page.school_login_has_failed()

        page = page.school_login(student_name, access_code, new_password)
        assert self.is_dashboard(page)
Exemple #4
0
    def test_deny_join(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)
        _, class_name, access_code = create_class_directly(email_1)
        create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .login_no_school(email_2, password_2) \
            .join_organisation(name)

        assert page.__class__.__name__ == 'OnboardingRevokeRequestPage'

        page = page \
            .logout() \
            .go_to_login_page() \
            .login(email_1, password_1)

        assert page.has_join_request(email_2)
        page = page.deny_join_request()

        assert not page.has_join_request(email_2)

        page = page \
            .logout() \
            .go_to_login_page() \
            .login_no_school(email_2, password_2)

        assert page.__class__.__name__ == 'OnboardingOrganisationPage'
    def test_update_password_success(self):
        email, _ = signup_teacher_directly()
        create_organisation_directly(email)
        _, _, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.selenium.get(self.live_server_url)
        page = (
            HomePage(self.selenium)
            .go_to_login_page()
            .student_login(student_name, access_code, student_password)
        )
        assert self.is_dashboard(page)

        new_password = "******"

        page = page.go_to_account_page().update_password_failure(
            new_password, new_password, student_password
        )
        assert is_student_details_updated_message_showing(self.selenium)

        page.logout()
        self.selenium.get(self.live_server_url)
        page = (
            HomePage(self.selenium)
            .go_to_login_page()
            .student_login(student_name, access_code, new_password)
        )
        assert self.is_dashboard(page)
Exemple #6
0
    def test_edit_clash(self):
        email_1, _ = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        school_name_1, postcode_1 = create_organisation_directly(email_1)
        create_organisation_directly(email_2)
        _, _, access_code_1 = create_class_directly(email_1)
        _, _, access_code_2 = create_class_directly(email_2)
        create_school_student_directly(access_code_1)
        create_school_student_directly(access_code_2)

        self.selenium.get(self.live_server_url)
        page = HomePage(self.selenium).go_to_login_page().login(
            email_2, password_2)

        assert not page.check_organisation_details({
            "name": school_name_1,
            "postcode": postcode_1
        })

        page = page.change_organisation_details({
            "name": school_name_1,
            "postcode": postcode_1
        })

        assert page.has_edit_failed()
    def test_move(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email_1)
        join_teacher_to_organisation(email_2, org_name, postcode)
        _, class_name_1, access_code_1 = create_class_directly(email_1)
        _, class_name_2, access_code_2 = create_class_directly(email_2)
        student_name_1, student_password_1, _ = create_school_student_directly(
            access_code_1
        )
        student_name_2, student_password_2, _ = create_school_student_directly(
            access_code_1
        )

        self.selenium.get(self.live_server_url)
        page = HomePage(self.selenium).go_to_login_page().login(email_1, password_1)
        page = page.go_to_class_page()
        assert page.student_exists(student_name_1)
        assert page.student_exists(student_name_2)

        page = page.toggle_select_student()
        page = page.move_students().select_class_by_index(0).move().move()
        assert not page.student_exists(student_name_1)

        page = page.go_to_dashboard()
        page = page.go_to_top().logout().go_to_login_page().login(email_2, password_2)
        page = page.go_to_class_page()
        assert page.student_exists(student_name_1)
    def test_teach(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)
        page = page.go_to_teach_page()

        page = page.go_to_student_login_page().go_to_teach_page()

        page = page.go_to_forgotten_password_page().cancel().go_to_teach_page()
    def test_teach(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)
        page = page.go_to_teach_page()

        page = page.go_to_student_login_page().go_to_teach_page()

        page = page.go_to_forgotten_password_page().cancel().go_to_teach_page()
 def test_login_failure(self):
     selenium.get(self.live_server_url)
     page = HomePage(selenium)
     page = page.go_to_teach_page()
     page = page.login_failure('*****@*****.**',
                               'Incorrect password')
     assert page.has_login_failed()
     assert self.is_teach_page(page)
    def test_create_empty(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_students(email, password).create_students_empty()

        assert page.was_form_empty('form-create-students')
Exemple #12
0
    def test_create_invalid_postcode(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_school(
            email, password)

        page = page.create_organisation_failure('School', password, '   ')
        assert page.was_postcode_invalid()
Exemple #13
0
    def test_create_empty(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_school(
            email, password)

        page = page.create_organisation_empty()
        assert page.was_form_empty('form-create-organisation')
Exemple #14
0
    def test_join(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        selenium.get(self.live_server_url)
        page = HomePage(selenium)\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_create_or_join_page()\
            .join_organisation(name)

        page = page\
            .logout()\
            .go_to_teach_page()\
            .login(email_1, password_1)\
            .go_to_organisation_manage_page()

        assert page.has_join_request(email_2)
        page = page.accept_join_request(email_2)

        assert page.has_no_join_requests()
        assert page.number_of_members() == 2
        assert page.number_of_admins() == 1

        page = page\
            .logout()\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_manage_page()

        assert page.check_organisation_name(name)
        assert page.is_not_admin_view()
Exemple #15
0
    def test_create_clash(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .login_no_school(email_2, password_2) \
            .create_organisation_failure(name, password_2, postcode)

        assert page.has_creation_failed()
Exemple #16
0
    def test_login_nonexistent_class(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .student_login_failure(student_name, 'WRONG', student_password)

        assert page.has_login_failed('form-login-school', 'Invalid name, class access code or password')
    def test_login_failure(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium)\
            .go_to_play_page()\
            .school_login_incorrect(student_name, access_code, 'some other password')

        assert page.school_login_has_failed()
    def test_create(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_students(email, password)

        page, student_name = create_school_student(page)
        assert page.student_exists(student_name)

        assert page.__class__.__name__ == 'OnboardingStudentListPage'
    def test_create_multiple(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_students(email, password)

        page, student_names = create_many_school_students(page, 12)

        for student_name in student_names:
            assert page.student_exists(student_name)
    def test_create(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.does_not_have_students()

        page, student_name, student_password = create_school_student(page)
        assert page.has_students()
        assert page.student_exists(student_name)
Exemple #21
0
    def test_login_failure(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(
            access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium)\
            .go_to_play_page()\
            .school_login_incorrect(student_name, access_code, 'some other password')

        assert page.school_login_has_failed()
    def test_revoke(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email_2, password_2).go_to_organisation_create_or_join_page()
        page = page.join_organisation(name)
        assert page.__class__.__name__ == "TeachOrganisationRevokePage"
        assert page.check_organisation_name(name, postcode)

        page = page.revoke_join()
        assert page.__class__.__name__ == "TeachOrganisationCreatePage"
    def test_create_clash(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser)\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_create_or_join_page()\
            .create_organisation_failure(name, password_2, postcode)

        assert page.has_creation_failed()
    def test_login_success(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)
        page, email, password = signup_teacher(page)
        page = page.login(email, password)
        assert self.is_teacher_dashboard(page)

        page = page.go_to_account_page()
        assert page.check_account_details({
            'title': 'Mr',
            'first_name': 'Test',
            'last_name': 'Teacher',
        })
    def test_login_success(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)
        page, email, password = signup_teacher(page)
        page = page.login(email, password)
        assert self.is_teacher_dashboard(page)

        page = page.go_to_account_page()
        assert page.check_account_details({
            'title': 'Mr',
            'first_name': 'Test',
            'last_name': 'Teacher',
        })
    def test_create_duplicate(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        student_name = 'bob'

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login_no_students(email, password)

        page = page.type_student_name(student_name).type_student_name(student_name).create_students_failure()
        assert page.adding_students_failed()
        assert page.duplicate_students(student_name)
    def test_join(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser)\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_create_or_join_page()\
            .join_organisation(name)

        page = page\
            .logout()\
            .go_to_teach_page()\
            .login(email_1, password_1)\
            .go_to_organisation_manage_page()

        assert page.has_join_request(email_2)
        page = page.accept_join_request(email_2)

        assert page.has_no_join_requests()
        assert page.number_of_members() == 2
        assert page.number_of_admins() == 1

        page = page\
            .logout()\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_manage_page()

        assert page.check_organisation_name(name)
        assert page.is_not_admin_view()
    def test_generate_random_student_password(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        name, password, student = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login(email, password).go_to_class_page().go_to_edit_student_page()

        assert page.is_student_name(name)

        page = page.click_generate_password_button()

        assert page.__class__.__name__ == 'EditStudentPasswordPage'
    def test_edit_clash(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name_1, postcode_1 = create_organisation_directly(email_1)
        name_2, postcode_2 = create_organisation_directly(email_2)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email_2, password_2).go_to_organisation_manage_page()

        assert not page.check_organisation_details({"name": name_1, "postcode": postcode_1})

        page = page.change_organisation_details({"name": name_1, "postcode": postcode_1})

        assert page.has_edit_failed()
    def test_edit_details(self):
        email, password = signup_teacher_directly()
        name, postcode = create_organisation_directly(email)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password).go_to_organisation_manage_page()

        assert page.check_organisation_details({"name": name, "postcode": postcode})

        new_name = "new " + name
        new_postcode = "OX2 6LE"

        page.change_organisation_details({"name": new_name, "postcode": new_postcode})
        assert page.check_organisation_details({"name": new_name, "postcode": new_postcode})
Exemple #31
0
    def test_update_password_form_empty(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .student_login(student_name, access_code, student_password)
        assert self.is_dashboard(page)

        page = page.go_to_account_page().submit_empty_form()
        assert self.is_account_page(page)
        assert page.was_form_invalid('This field is required.')
Exemple #32
0
    def test_revoke(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .login_no_school(email_2, password_2)
        page = page.join_organisation(name)
        assert page.__class__.__name__ == 'OnboardingRevokeRequestPage'
        assert page.check_organisation_name(name, postcode)

        page = page.revoke_join()
        assert page.__class__.__name__ == 'OnboardingOrganisationPage'
    def test_add_to_existing_class(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_login_page().login(email, password).go_to_class_page()

        page, new_student_name = create_school_student(page)
        assert page.student_exists(new_student_name)

        page = page.go_back_to_class()

        assert page.student_exists(new_student_name)
Exemple #34
0
    def test_update_password_passwords_not_match(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .student_login(student_name, access_code, student_password)
        assert self.is_dashboard(page)

        page = page.go_to_account_page().update_password_failure('NewPassword', 'OtherPassword', student_password)
        assert self.is_account_page(page)
        assert page.was_form_invalid('Your new passwords do not match')
Exemple #35
0
    def test_update_password_too_weak(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        selenium.get(self.live_server_url)
        page = HomePage(selenium) \
            .go_to_login_page() \
            .student_login(student_name, access_code, student_password)
        assert self.is_dashboard(page)

        page = page.go_to_account_page().update_password_failure('tiny', 'tiny', student_password)
        assert self.is_account_page(page)
        assert page.was_form_invalid('Password not strong enough, consider using at least 6 characters')
    def test_create_multiple(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.does_not_have_students()

        page, student_names, student_passwords = create_many_school_students(page, 12)

        assert page.has_students()
        for student_name in student_names:
            assert page.student_exists(student_name)
Exemple #37
0
    def test_kick(self):
        email_1, password_1 = signup_teacher_directly()
        name, _ = create_organisation_directly(email_1)
        _, _, access_code = create_class_directly(email_1)
        create_school_student_directly(access_code)

        title, first_name, _, email_2, password_2 = generate_details()

        new_last_name = "New Teacher"

        self.selenium.get(self.live_server_url)
        page = (HomePage(self.selenium).go_to_signup_page().signup(
            title, first_name, new_last_name, email_2, password_2, password_2))

        page = email_utils.follow_verify_email_link_to_onboarding(
            page, mail.outbox[0])
        mail.outbox = []

        page = page.login_no_school(email_2,
                                    password_2).join_organisation(name)

        assert page.__class__.__name__ == "OnboardingRevokeRequestPage"

        page = page.logout().go_to_login_page().login(email_1, password_1)

        page = page.accept_join_request()

        assert page.is_teacher_in_school(new_last_name)

        page = page.click_kick_button()
        assert page.is_dialog_showing()
        page = page.confirm_dialog()

        assert page.is_not_teacher_in_school(new_last_name)
Exemple #38
0
    def test_move(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email_1)
        join_teacher_to_organisation(email_2, org_name, postcode)
        _, _, access_code_1 = create_class_directly(email_1)
        _, _, _ = create_class_directly(email_2)
        student_name_1, _, _ = create_school_student_directly(access_code_1)
        student_name_2, _, _ = create_school_student_directly(access_code_1)

        self.selenium.get(self.live_server_url)
        page = (HomePage(self.selenium).go_to_teacher_login_page().login(
            email_1, password_1))
        page = page.go_to_class_page()
        assert page.student_exists(student_name_1)
        assert page.student_exists(student_name_2)

        page = page.toggle_select_student()
        page = page.move_students().select_class_by_index(0).move().move()
        assert not page.student_exists(student_name_1)

        page = page.go_to_dashboard()
        page = (page.go_to_top().logout().go_to_teacher_login_page().login(
            email_2, password_2))
        page = page.go_to_class_page()
        assert page.student_exists(student_name_1)
    def test_allow_join(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)
        _, class_name, access_code = create_class_directly(email_1)
        create_school_student_directly(access_code)

        self.selenium.get(self.live_server_url)
        page = (HomePage(
            self.selenium).go_to_teacher_login_page().login_no_school(
                email_2, password_2).join_organisation(name))

        assert page.__class__.__name__ == "OnboardingRevokeRequestPage"

        page = page.logout().go_to_teacher_login_page().login(
            email_1, password_1)

        assert page.has_join_request(email_2)
        page = page.accept_join_request()

        assert not page.has_join_request(email_2)

        page = (page.logout().go_to_teacher_login_page().login_no_class(
            email_2, password_2))

        assert page.__class__.__name__ == "OnboardingClassesPage"
Exemple #40
0
    def test_revoke(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        name, postcode = create_organisation_directly(email_1)

        selenium.get(self.live_server_url)
        page = HomePage(selenium)\
            .go_to_teach_page()\
            .login(email_2, password_2)\
            .go_to_organisation_create_or_join_page()
        page = page.join_organisation(name)
        assert page.__class__.__name__ == 'TeachOrganisationRevokePage'
        assert page.check_organisation_name(name, postcode)

        page = page.revoke_join()
        assert page.__class__.__name__ == 'TeachOrganisationCreatePage'
Exemple #41
0
    def logout(self):
        self.browser.find_element_by_id('logout_menu').click()

        self.browser.find_element_by_id('logout_button').click()
        from portal.tests.pageObjects.portal.home_page import HomePage

        return HomePage(self.browser)
    def logout(self):
        self.open_user_options_box()
        self.browser.find_element_by_id("logout_button").click()

        from portal.tests.pageObjects.portal.home_page import HomePage

        return HomePage(self.browser)
 def test_base(self):
     selenium.get(self.live_server_url)
     page = HomePage(selenium)
     page = page.go_to_about_page()
     page = page.go_to_contact_page()
     page = page.go_to_terms_page()
     page = page.go_to_help_page()
     page = page.go_to_play_page()
     page = page.go_to_teach_page()
Exemple #44
0
    def test_join_empty(self):
        email, password = signup_teacher_directly()

        self.selenium.get(self.live_server_url)
        page = (HomePage(self.selenium).go_to_login_page().login_no_school(
            email, password).join_empty_organisation())

        assert page.__class__.__name__ == "OnboardingOrganisationPage"
    def test_dismiss(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name_1, student_password_1, _ = create_school_student_directly(
            access_code
        )
        student_name_2, student_password_2, _ = create_school_student_directly(
            access_code
        )

        self.selenium.get(self.live_server_url)
        page = HomePage(self.selenium).go_to_login_page().login(email, password)
        page = page.go_to_class_page()
        assert page.student_exists(student_name_1)

        page = page.toggle_select_student().dismiss_students()
        assert page.__class__.__name__ == "TeachDismissStudentsPage"
        page = page.cancel()
        assert page.__class__.__name__ == "TeachClassPage"

        page = (
            page.toggle_select_student()
            .dismiss_students()
            .enter_email("*****@*****.**")
            .dismiss()
        )
        assert not page.student_exists(student_name_1)
    def test_move_cancel(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.selenium.get(self.live_server_url)
        page = HomePage(self.selenium).go_to_login_page().login(email, password)
        page = page.go_to_class_page()

        page = page.move_students_none_selected()
        assert page.__class__.__name__ == "TeachClassPage"

        page = page.toggle_select_student().move_students()
        assert page.__class__.__name__ == "TeachMoveStudentsPage"

        page = page.cancel()
        assert page.__class__.__name__ == "TeachClassPage"
    def test_change_password(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password)

        page = page.go_to_account_page()
        new_password = '******'
        page = page.change_teacher_details({
            'password': new_password,
            'confirm_password': new_password,
            'current_password': password,
        })
        assert self.is_teacher_dashboard(page)
        assert is_teacher_details_updated_message_showing(selenium)

        page = page.logout().go_to_teach_page().login(email, new_password)
        assert self.is_teacher_dashboard(page)
 def test_base(self):
     selenium.get(self.live_server_url)
     page = HomePage(selenium)
     page = page.go_to_about_page()
     page = page.go_to_contact_page()
     page = page.go_to_terms_page()
     page = page.go_to_help_page()
     page = page.go_to_play_page()
     page = page.go_to_teach_page()
    def test_create_already_exists(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.has_students()
        assert page.student_exists(student_name)

        page = page.type_student_name(student_name).create_students_failure()
        assert self.is_class_page(page)
        assert page.adding_students_failed()
        assert page.student_already_existed(student_name)
        assert page.has_students()
        assert page.student_exists(student_name)
    def test_edit_details(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password)

        page = page.go_to_account_page()
        page = page.change_teacher_details({
            'title': 'Mrs',
            'first_name': 'Paulina',
            'last_name': 'Koch',
            'current_password': '******',
        })
        assert self.is_teacher_dashboard(page)
        assert is_teacher_details_updated_message_showing(selenium)

        page = page.go_to_account_page()
        assert page.check_account_details({
            'title': 'Mrs',
            'first_name': 'Paulina',
            'last_name': 'Koch',
        })
    def test_create_duplicate(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)

        student_name = 'bob'

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.does_not_have_students()
        assert page.student_does_not_exist(student_name)

        page = page.type_student_name(student_name).type_student_name(student_name).create_students_failure()
        assert self.is_class_page(page)
        assert page.adding_students_failed()
        assert page.duplicate_students(student_name)
        assert page.does_not_have_students()
        assert page.student_does_not_exist(student_name)
    def test_move_cancel_disambiguate(self):
        email_1, password_1 = signup_teacher_directly()
        email_2, password_2 = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email_1)
        join_teacher_to_organisation(email_2, org_name, postcode)
        _, class_name_1, access_code_1 = create_class_directly(email_1)
        _, class_name_2, access_code_2 = create_class_directly(email_2)
        student_name, student_password, _ = create_school_student_directly(access_code_1)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email_1, password_1)
        page = page.go_to_classes_page().go_to_class_page(class_name_1)
        assert page.has_students()
        assert page.student_exists(student_name)

        page = page.toggle_select_student(student_name)
        page = page.move_students().select_class_by_index(0).move().cancel()
        assert page.has_students()
        assert page.student_exists(student_name)
    def test_delete(self):
        email, password = signup_teacher_directly()
        create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.selenium.get(self.live_server_url)
        page = HomePage(self.selenium).go_to_login_page().login(email, password)
        page = page.go_to_class_page()
        assert page.student_exists(student_name)

        page = page.toggle_select_student().delete_students()
        assert page.is_dialog_showing()
        page = page.confirm_delete_student_dialog()

        assert not page.student_exists(student_name)
    def test_move_cancel(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.has_students()
        assert page.student_exists(student_name)

        page = page.move_students_none_selected()
        assert self.is_class_page(page)

        page = page.toggle_select_student(student_name).move_students()
        assert page.__class__.__name__ == 'TeachMoveStudentsPage'
        assert page.get_list_length() == 0

        page = page.cancel()
    def test_create(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password)

        page, name, postcode = create_organisation(page, password)
        assert is_organisation_created_message_showing(selenium, name)

        page = page.go_to_organisation_manage_page()
        assert page.is_admin_view()
        assert page.number_of_members() == 1
        assert page.number_of_admins() == 1
        assert page.check_organisation_details({"name": name, "postcode": postcode})
    def test_change_email(self):
        email, password = signup_teacher_directly()

        selenium.get(self.live_server_url)
        page = HomePage(selenium).go_to_teach_page().login(email, password)

        page = page.go_to_account_page()
        new_email = '*****@*****.**'
        page = page.change_email(new_email, password)
        assert page.__class__.__name__ == 'EmailVerificationNeededPage'
        assert is_teacher_email_updated_message_showing(selenium)

        page = email_utils.follow_change_email_link_to_teach(page, mail.outbox[0])
        mail.outbox = []

        page = page.login(new_email, password)

        page = page.go_to_account_page()
        assert page.check_account_details({
            'title': 'Mr',
            'first_name': 'Test',
            'last_name': 'Teacher',
        })
    def test_home(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)

        page = page.go_to_teacher_sign_up().go_to_home_page()
    def test_play(self):
        selenium.get(self.live_server_url)
        page = HomePage(selenium)
        page = page.go_to_play_page()

        page = page.go_to_teacher_login().go_to_play_page()
        page.show_independent_student_login()
        page = page.go_to_teacher_login().go_to_play_page()
        page.show_school_login()

        assert page.is_in_school_login_state()
        assert page.not_showing_intependent_student_signup_form()

        page.show_independent_student_login()

        assert page.is_in_independent_student_login_state()
        assert page.not_showing_intependent_student_signup_form()

        page.show_school_login()

        assert page.is_in_school_login_state()
        assert page.not_showing_intependent_student_signup_form()

        page.show_independent_student_signup()

        assert page.is_in_school_login_state()
        assert page.showing_intependent_student_signup_form()

        page.show_independent_student_login()

        assert page.is_in_independent_student_login_state()
        assert page.showing_intependent_student_signup_form()

        page.show_school_login()

        assert page.is_in_school_login_state()
        assert page.showing_intependent_student_signup_form()

        page.show_independent_student_login()
        page = page.go_to_forgotten_password_page().cancel().go_to_play_page()
    def test_dismiss(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name_1, student_password_1, _ = create_school_student_directly(access_code)
        student_name_2, student_password_2, _ = create_school_student_directly(access_code)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.has_students()
        assert page.student_exists(student_name_1)
        assert page.student_exists(student_name_2)

        page = page.dismiss_students_none_selected()
        assert self.is_class_page(page)

        page = page.toggle_select_student(student_name_1).dismiss_students()
        assert page.__class__.__name__ == 'TeachDismissStudentsPage'
        page = page.cancel()
        assert page.has_students()
        assert page.student_exists(student_name_1)
        assert page.student_exists(student_name_2)

        page = page.toggle_select_student(student_name_1)
        page, emails = dismiss_students(page)
        assert page.has_students()
        assert page.student_does_not_exist(student_name_1)
        assert page.student_exists(student_name_2)
    def test_delete(self):
        email, password = signup_teacher_directly()
        org_name, postcode = create_organisation_directly(email)
        _, class_name, access_code = create_class_directly(email)
        student_name, student_password, _ = create_school_student_directly(access_code)

        self.browser.get(self.live_server_url)
        page = HomePage(self.browser).go_to_teach_page().login(email, password)
        page = page.go_to_classes_page().go_to_class_page(class_name)
        assert page.has_students()
        assert page.student_exists(student_name)

        page = page.toggle_select_student(student_name).delete_students()
        assert page.is_dialog_showing()
        page = page.cancel_dialog()
        assert not page.is_dialog_showing()
        assert page.has_students()
        assert page.student_exists(student_name)

        page = page.delete_students()
        assert page.is_dialog_showing()
        page = page.confirm_dialog_expect_error()
        assert page.does_not_have_students()
        assert page.student_does_not_exist(student_name)