Skip to content

Commit

Permalink
update tests for relative redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Mar 25, 2022
1 parent ce7b884 commit 568fc25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/tutorial/tests.rst
Expand Up @@ -266,7 +266,7 @@ messages.
response = client.post(
'/auth/register', data={'username': 'a', 'password': 'a'}
)
assert 'http://localhost/auth/login' == response.headers['Location']
assert response.headers["Location"] == "/auth/login"
with app.app_context():
assert get_db().execute(
Expand Down Expand Up @@ -319,7 +319,7 @@ The tests for the ``login`` view are very similar to those for
def test_login(client, auth):
assert client.get('/auth/login').status_code == 200
response = auth.login()
assert response.headers['Location'] == 'http://localhost/'
assert response.headers["Location"] == "/"
with client:
client.get('/')
Expand Down Expand Up @@ -404,7 +404,7 @@ is returned. If a ``post`` with the given ``id`` doesn't exist,
))
def test_login_required(client, path):
response = client.post(path)
assert response.headers['Location'] == 'http://localhost/auth/login'
assert response.headers["Location"] == "/auth/login"
def test_author_required(app, client, auth):
Expand Down Expand Up @@ -479,7 +479,7 @@ no longer exist in the database.
def test_delete(client, auth, app):
auth.login()
response = client.post('/1/delete')
assert response.headers['Location'] == 'http://localhost/'
assert response.headers["Location"] == "/"
with app.app_context():
db = get_db()
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial/tests/test_auth.py
Expand Up @@ -11,7 +11,7 @@ def test_register(client, app):

# test that successful registration redirects to the login page
response = client.post("/auth/register", data={"username": "a", "password": "a"})
assert "http://localhost/auth/login" == response.headers["Location"]
assert response.headers["Location"] == "/auth/login"

# test that the user was inserted into the database
with app.app_context():
Expand Down Expand Up @@ -42,7 +42,7 @@ def test_login(client, auth):

# test that successful login redirects to the index page
response = auth.login()
assert response.headers["Location"] == "http://localhost/"
assert response.headers["Location"] == "/"

# login request set the user_id in the session
# check that the user is loaded from the session
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial/tests/test_blog.py
Expand Up @@ -19,7 +19,7 @@ def test_index(client, auth):
@pytest.mark.parametrize("path", ("/create", "/1/update", "/1/delete"))
def test_login_required(client, path):
response = client.post(path)
assert response.headers["Location"] == "http://localhost/auth/login"
assert response.headers["Location"] == "/auth/login"


def test_author_required(app, client, auth):
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_create_update_validate(client, auth, path):
def test_delete(client, auth, app):
auth.login()
response = client.post("/1/delete")
assert response.headers["Location"] == "http://localhost/"
assert response.headers["Location"] == "/"

with app.app_context():
db = get_db()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_regression.py
Expand Up @@ -19,6 +19,6 @@ def test():

with app.test_client() as c:
rv = c.get("/")
assert rv.headers["Location"] == "http://localhost/test"
assert rv.headers["Location"] == "/test"
rv = c.get("/test")
assert rv.data == b"42"

0 comments on commit 568fc25

Please sign in to comment.