auth tests
This commit is contained in:
@@ -25,3 +25,21 @@ def test_register_validate_input(client, username, password, message):
|
|||||||
data={'username': username, 'password': password}
|
data={'username': username, 'password': password}
|
||||||
)
|
)
|
||||||
assert message in response.data
|
assert message in response.data
|
||||||
|
|
||||||
|
def test_login(client, auth):
|
||||||
|
assert client.get('/auth/login').status_code == 200
|
||||||
|
response = auth.login()
|
||||||
|
assert response.headers['Location'] == 'http://localhost/'
|
||||||
|
|
||||||
|
with client:
|
||||||
|
client.get('/')
|
||||||
|
assert session['user_id'] == 1
|
||||||
|
assert g.user['username'] == 'test'
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(('username', 'password', 'message'), (
|
||||||
|
('a', 'test', b'Incorrect username'),
|
||||||
|
('test', 'a', b'Incorrect password.'),
|
||||||
|
))
|
||||||
|
def test_login_validate_input(auth, username, password, message):
|
||||||
|
response = auth.login(username, password)
|
||||||
|
assert message in response.data
|
||||||
|
|||||||
Reference in New Issue
Block a user