fixed typos and added tests for db and auth
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import pytest
|
||||
from flask import g, session
|
||||
from flaskfdx.db import get_db
|
||||
|
||||
def test_register(client, app):
|
||||
assert client.get('/auth/register').status_code == 200
|
||||
response = client.post(
|
||||
'auth/register', data={'username': 'a', 'password': 'a'}
|
||||
)
|
||||
assert 'http://localhost/auth/login' == response.headers['Location']
|
||||
|
||||
with app.app_context():
|
||||
assert get_db().execute(
|
||||
"SELECT * FROM users WHERE username = 'a'",
|
||||
).fetchone() is not None
|
||||
|
||||
@pytest.mark.parametrize(('username', 'password', 'message'), (
|
||||
('', '', b'Username is required.'),
|
||||
('a', '', b'Password is required.'),
|
||||
('test', 'test', b'already registered'),
|
||||
))
|
||||
def test_register_validate_input(client, username, password, message):
|
||||
response = client.post(
|
||||
'/auth/register',
|
||||
data={'username': username, 'password': password}
|
||||
)
|
||||
assert message in response.data
|
||||
Reference in New Issue
Block a user