Our custom ordering system
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.
 
 
 
 
 
 

151 lines
4.5 KiB

import pytest
@pytest.mark.functional
def test_registration_procedure(testapp, login_as, parse_latest_mail):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric" # noqa: S105
response = form.submit("Create_Account").follow()
assert "The account needs to be activated" in response
response = login_as("TestNew", "eric")
assert "Credentials are invalid" in response
login_as("TestAdmin", "jane")
response = testapp.get("/users/?role=new", status=200)
assert "TestNew" in response
response = testapp.get("/users/TestNew/edit", status=200)
assert "Edit User" in response
form = response.forms[1]
form["role"].select(text="User")
response = form.submit("Save_Changes").follow()
assert "TestNew" in response
response = testapp.get("/users/?role=new", status=200)
assert "TestNew" not in response
response = testapp.get("/users/?role=user", status=200)
assert "TestNew" in response
parsed = parse_latest_mail()
assert "Your account was activated" in parsed.body
response = login_as("TestNew", "eric").follow()
assert "My Orders" in response
@pytest.mark.functional
def test_registration_procedure_form_error(
testapp,
login_as, # noqa: ARG001
parse_latest_mail, # noqa: ARG001
):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
response = form.submit("Create_Account")
assert "There was a problem with your submission" in response
@pytest.mark.functional
def test_registration_procedure_not_unique_username(
testapp,
login_as, # noqa: ARG001
parse_latest_mail, # noqa: ARG001
):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestAdmin"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric" # noqa: S105
response = form.submit("Create_Account")
assert "There was a problem with your submission" in response
@pytest.mark.functional
def test_registration_procedure_not_unique_email(
testapp,
login_as, # noqa: ARG001
parse_latest_mail, # noqa: ARG001
):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "jane@example.com"
form["password"] = "eric" # noqa: S105
response = form.submit("Create_Account")
assert "There was a problem with your submission" in response
@pytest.mark.functional
def test_registration_procedure_bad_csrf_token(
testapp,
login_as, # noqa: ARG001
parse_latest_mail, # noqa: ARG001
):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["csrf_token"] = "bad token" # noqa: S105
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric" # noqa: S105
form.submit("Create_Account", status=400)
@pytest.mark.functional
def test_registration_procedure_canceled(testapp, login_as, parse_latest_mail): # noqa: ARG001
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric" # noqa: S105
response = form.submit("Cancel").follow(status=302).follow()
assert "Please Log In" in response