MCPcopy
hub / github.com/pallets/flask / test_register

Function test_register

examples/tutorial/tests/test_auth.py:8–21  ·  view source on GitHub ↗
(client, app)

Source from the content-addressed store, hash-verified

6
7
8def test_register(client, app):
9 # test that viewing the page renders without template errors
10 assert client.get("/auth/register").status_code == 200
11
12 # test that successful registration redirects to the login page
13 response = client.post("/auth/register", data={"username": "a", "password": "a"})
14 assert response.headers["Location"] == "/auth/login"
15
16 # test that the user was inserted into the database
17 with app.app_context():
18 assert (
19 get_db().execute("SELECT * FROM user WHERE username = 'a'").fetchone()
20 is not None
21 )
22
23
24@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

get_dbFunction · 0.90
app_contextMethod · 0.80
getMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected