auth tests

This commit is contained in:
2021-10-12 13:25:36 -06:00
parent 30b21dbde6
commit a10aba5bdc
+18
View File
@@ -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