You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
5.2 KiB
168 lines
5.2 KiB
import pytest |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_edit(testapp, login_as): |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestUser/edit") |
|
form = response.forms[1] |
|
form["first_name"] = "Terry" |
|
form["last_name"] = "Gilliam" |
|
form["email"] = "terry@example.com" |
|
form.submit("Save_Changes") |
|
|
|
response = testapp.get("/users/", status=200) |
|
assert "Jon" not in response |
|
assert "Smith" not in response |
|
assert "jon@example.com" not in response |
|
assert "Terry" in response |
|
assert "Gilliam" in response |
|
assert "terry@example.com" in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_edit_cancel(testapp, login_as): |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestUser/edit") |
|
form = response.forms[1] |
|
form["first_name"] = "Terry" |
|
form["last_name"] = "Gilliam" |
|
form["email"] = "terry@example.com" |
|
form.submit("Cancel") |
|
|
|
response = testapp.get("/users/", status=200) |
|
assert "Jon" in response |
|
assert "Smith" in response |
|
assert "jon@example.com" in response |
|
assert "Terry" not in response |
|
assert "Gilliam" not in response |
|
assert "terry@example.com" not in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_edit_form_error(testapp, login_as): |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestUser/edit") |
|
form = response.forms[1] |
|
form["first_name"] = "" |
|
response = form.submit("Save_Changes") |
|
assert "There was a problem with your submission" in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_edit_invalid_user(testapp, login_as): |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/Unknown/edit").follow() |
|
assert "My Orders" in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_edit_reset_password(testapp, login_as, parse_latest_mail): |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestUser/edit") |
|
assert "Reset Password" in response |
|
assert "Delte User" not in response |
|
|
|
response = testapp.get("/users/TestUser/password").follow() |
|
assert "jon@example.com" in response |
|
assert "A password reset link has been sent" in response |
|
|
|
parsed = parse_latest_mail() |
|
assert "If you forgot your password" in parsed.body |
|
|
|
# same link target as forgotten password, rest is tested there |
|
assert parsed.link.startswith("http://localhost/reset?t=") |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_delete(testapp, login_as, parse_latest_mail): # noqa: ARG001 |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestInactive/edit") |
|
assert "Delete User" in response |
|
|
|
response = testapp.get("/users/TestInactive/delete") |
|
assert "I confirm that I want to delete this user." in response |
|
|
|
form = response.forms[1] |
|
form["confirmation"].checked = True |
|
form.submit("delete") |
|
|
|
response = testapp.get("/users") |
|
assert "has been deleted" in response |
|
assert "TestInactive" not in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_delete_cancel(testapp, login_as, parse_latest_mail): # noqa: ARG001 |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestInactive/edit") |
|
assert "Delete User" in response |
|
|
|
response = testapp.get("/users/TestInactive/delete") |
|
assert "I confirm that I want to delete this user." in response |
|
|
|
form = response.forms[1] |
|
form["confirmation"].checked = True |
|
form.submit("cancel") |
|
|
|
response = testapp.get("/users") |
|
assert "has been deleted" not in response |
|
assert "TestInactive" in response |
|
|
|
|
|
@pytest.mark.functional |
|
def test_user_delete_no_confirm(testapp, login_as, parse_latest_mail): # noqa: ARG001 |
|
response = testapp.get("/", status=302).follow() |
|
assert "Please Log In" in response |
|
|
|
response = login_as("TestAdmin", "jane").follow() |
|
assert "My Orders" in response |
|
|
|
response = testapp.get("/users/TestInactive/edit") |
|
assert "Delete User" in response |
|
|
|
response = testapp.get("/users/TestInactive/delete") |
|
assert "I confirm that I want to delete this user." in response |
|
|
|
form = response.forms[1] |
|
form["confirmation"].checked = False |
|
form.submit("delete") |
|
|
|
response = testapp.get("/users") |
|
assert "has been deleted" not in response |
|
assert "TestInactive" in response
|
|
|